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

namespace YBDevice.NWeb.Pages.Device
{
    /// <summary>
    /// 设备管理
    /// </summary>
    public class IndexModel : BaseModel
    {
        /// <summary>
        /// 设备类型列表
        /// </summary>
        public List<YB_DeviceType> types = new List<YB_DeviceType>();
        public List<SelectListItem> statuss = new List<SelectListItem>();
        public List<YB_Business> buss = new List<YB_Business>();
        private IDeviceService _deviceService;
        private IBusinessService _businessService;
        private IViewEngineService _viewEngineService;
        public ViewS2SDto viewdata = new ViewS2SDto();
        public IndexModel(IDeviceService deviceService,IBusinessService businessService, IViewEngineService viewEngineService)
        {
            _deviceService = deviceService;
            _businessService = businessService;
            _viewEngineService = viewEngineService;
        }

        public async Task OnGetAsync()
        {
            statuss = EnumHelper.GetEnumDictionary<DeviceStatus>().Select(x => new SelectListItem
            {
                Value = x.Key.ToString(),
                Text = x.Value
            }).ToList();
            types = await _deviceService.GetTypeListAsync();
            buss = await _businessService.GetAllListAsync();
            viewdata = await _viewEngineService.GetBtnListAsync();
        }
    }
}