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

namespace YBDevice.NWeb.Pages.Device
{
    /// <summary>
    /// Éè±¸ÀàÐÍ±à¼­
    /// </summary>
    public class EditTypeModel : BaseModel
    {
        public YB_DeviceType data = new YB_DeviceType();
        public List<SelectListItem> protypes = new List<SelectListItem>();
        public List<SelectListItem> vertypes = new List<SelectListItem>();
        private IDeviceService _deviceService;
        public EditTypeModel(IDeviceService deviceService)
        {
            _deviceService = deviceService;
        }
        public async Task OnGetAsync(int id = 0)
        {
            protypes = EnumHelper.GetEnumDictionary<DeviceProType>().Select(x => new SelectListItem
            {
                Value = x.Key.ToString(),
                Text = x.Value
            }).ToList();
            vertypes = EnumHelper.GetEnumDictionary<DeviceVerType>().Select(x => new SelectListItem
            {
                Value = x.Key.ToString(),
                Text = x.Value
            }).ToList();
            if (id > 0)
            {
                data = await _deviceService.TypeDetailAsync(id);
            }
        }
    }
}
