using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using YBDevice.Application;
using YBDevice.Entity;

namespace YBDevice.NWeb.Pages.Device
{
    /// <summary>
    /// 设备编辑
    /// </summary>
    public class EditModel : BaseModel
    {
        public YB_Device data = new YB_Device();
        public List<YB_DeviceType> types = new List<YB_DeviceType>();
        private IDeviceService _deviceService;
        public bool isedit = false;//是否可编辑,disabled不可编辑
        public EditModel(IDeviceService deviceService)
        {
            _deviceService = deviceService;
        }
        public async Task OnGetAsync(int id=0)
        {
            var BaseUser = BaseInfoService.GetUserInfo();
            if (BaseUser.AccountType != AccountType.platform)
            {
                isedit = true;
            }
            types = await _deviceService.GetTypeListAsync();
            if (id > 0)
            {
                data = await _deviceService.DetailAsync(id);
            }
        }
    }
}
