using Microsoft.AspNetCore.Mvc.Rendering;
using Nirvana.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using YBDevice.Application;
using YBDevice.Entity;

namespace YBDevice.NWeb.Pages.Info
{
    /// <summary>
    /// ×ÊÑ¶±à¼­
    /// </summary>
    public class EditModel : BaseModel
    {
        public SecInfoSubmitModel data = new SecInfoSubmitModel();
        public List<YB_SecInfoType> types = new List<YB_SecInfoType>();
        public List<SelectListItem> texttypes = new List<SelectListItem>();
        public List<YB_OfficlaAccount> offlist = new List<YB_OfficlaAccount>();
        private IInfoService _infoService;
        private IOfficialService _officialService;
        public List<string> appidlist = new List<string>();
        public EditModel(IInfoService infoService,IOfficialService officialService)
        {
            _infoService = infoService;
            _officialService = officialService;
        }
        public async Task OnGetAsync(Guid? id)
        {
            types = await _infoService.GetAllTypeAsync();
            texttypes = EnumHelper.GetEnumDictionary<AdType>().Select(x => new SelectListItem
            {
                Value = x.Key.ToString(),
                Text = x.Value
            }).ToList();
            offlist = await _officialService.GetAllListAsync(2);
            if (id.HasValue && id.Value !=Guid.Empty)
            {
                data = await _infoService.DetailAsync(id.Value);
                appidlist = data.AppId.Split(',').ToList();
            }
        }
    }
}
