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 Waste.Application;
using Waste.Domain;

namespace Waste.Web.Entry.Pages.Business
{
    /// <summary>
    /// ¿Í»§±à¼­
    /// </summary>
    public class EditModel : BaseModel
    {
        private readonly IBusinessService _partmentService;
        public BusinessInfo data = new BusinessInfo();
        public List<SelectListItem> accountypes = new List<SelectListItem>();
        public string provinceval = "";
        public string cityval = "";
        public string areaval = "";
        public bool IsAdmin = false;
        public EditModel(IBusinessService partmentService)
        {
            _partmentService = partmentService;
        }
        public async Task OnGetAsync(Guid? id=null)
        {
            if(OperatorProvider.Provider.GetCurrent().AccountType ==(int)AccountType.platform)
            {
                IsAdmin = true;
            }
            accountypes = EnumHelper.GetEnumDictionary<AccountType>().Select(x => new SelectListItem
            {
                Value = x.Key.ToString(),
                Text = x.Value
            }).ToList();
            if (id.HasValue && id.Value != Guid.Empty)
            {
                data = await _partmentService.DetailAsync(id.Value);
                provinceval = data.Province;
                cityval = data.City;
                areaval = data.Area;
            }
        }
    }
}
