using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using YBDevice.Application;
using YBDevice.Entity;

namespace YBDevice.NWeb.Pages.Device
{
    public class EditAppModel : BaseModel
    {
        public List<YB_DeviceType> types = new List<YB_DeviceType>();
        public YB_DeviceTypeApp data = new YB_DeviceTypeApp();
        public List<YB_OfficlaAccount> offlist = new List<YB_OfficlaAccount>();
        public List<string> typelist = new List<string>();
        private IDeviceService _deviceService;
        private IOfficialService _officialService;
        public EditAppModel(IDeviceService deviceService, IOfficialService officialService)
        {
            _deviceService = deviceService;
            _officialService = officialService;
        }
        public async Task OnGetAsync(Guid? id)
        {
            types = await _deviceService.GetTypeListAsync();
            offlist = await _officialService.GetAllListAsync(2);
            if (id.HasValue && id.Value != Guid.Empty)
            {
                data = await _deviceService.GetDeviceAppAsync(id.Value);
                typelist = data.DevType.Split(',').ToList();
            }
        }
    }
}
