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.Business
{
    /// <summary>
    /// ¿Í»§±à¼­
    /// </summary>
    public class EditModel : BaseModel
    {
        public BusinessSubmitModel data = new BusinessSubmitModel();
        public List<SelectListItem> accountypes = new List<SelectListItem>();
        public List<YB_nRole> rolelist = new List<YB_nRole>();
        private IBusinessService _businessService;
        private ISystemService _systemService;

        public EditModel(IBusinessService businessService, ISystemService systemService)
        {
            _businessService = businessService;
            _systemService = systemService;
        }
        public async Task OnGetAsync(int id=0)
        {
            accountypes = EnumHelper.GetEnumDictionary<AccountType>().Select(x => new SelectListItem
            {
                Value = x.Key.ToString(),
                Text = x.Value
            }).ToList();
            rolelist = await _systemService.GetAllRoleListAsync();
            if (id > 0)
            {
                data = await _businessService.DetailAsync(id);
            }
        }
    }
}
