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

namespace YBDevice.NWeb.Pages.Info
{
    /// <summary>
    /// 科普资讯
    /// </summary>
    public class IndexModel : BaseModel
    {
        /// <summary>
        /// 类型列表
        /// </summary>
        public List<SelectListItem> types;
        public List<SelectListItem> statuss = new List<SelectListItem>();
        public List<SelectListItem> offs = new List<SelectListItem>();
        private IInfoService _infoService;
        private IOfficialService _officialService;
        private IViewEngineService _viewEngineService;
        public ViewS2SDto viewdata = new ViewS2SDto();
        public IndexModel(IInfoService infoService, IOfficialService officialService, IViewEngineService viewEngineService)
        {
            _infoService = infoService;
            _officialService = officialService;
            _viewEngineService = viewEngineService;
        }
        public async Task OnGetAsync()
        {
            var list = await _infoService.GetAllTypeAsync();
            var offlist = await _officialService.GetAllListAsync(2);
            types = list.Select(x => new SelectListItem
            {
                Text = x.Name,
                Value = x.Id.ToString()
            }).ToList();
            offs = offlist.Select(x => new SelectListItem
            {
                Text = x.nick_name,
                Value = x.authorizer_appid.ToString()
            }).ToList();
            statuss = EnumHelper.GetEnumDictionary<AdStatus>().Select(x => new SelectListItem
            {
                Value = x.Key.ToString(),
                Text = x.Value
            }).ToList();
            viewdata = await _viewEngineService.GetBtnListAsync();
        }
    }
}
