using Microsoft.AspNetCore.Mvc.Rendering;
using Nirvana.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using YBDevice.Application;
using YBDevice.Entity;
namespace YBDevice.NWeb.Pages.Banner
{
///
/// ¹ã¸æ±à¼
///
public class EditModel : BaseModel
{
public BannerSubmitModel data = new BannerSubmitModel();
public List types = new List();
public List ptypes = new List();
public List offlist = new List();
public List devicetypes = new List();
private IAdService _infoService;
private IOfficialService _officialService;
private IDeviceService _deviceService;
public EditModel(IAdService infoService,IOfficialService officialService, IDeviceService deviceService)
{
_infoService = infoService;
_officialService = officialService;
_deviceService = deviceService;
}
public async Task OnGetAsync(int id=0)
{
types = EnumHelper.GetEnumDictionary().Select(x => new SelectListItem
{
Value = x.Key.ToString(),
Text = x.Value
}).ToList();
ptypes = EnumHelper.GetEnumDictionary()
.Where(x=>x.Key != 2)
.Select(x => new SelectListItem
{
Value = x.Key.ToString(),
Text = x.Value
}).ToList();
devicetypes = await _deviceService.GetTypeListAsync();
offlist = await _officialService.GetAllListAsync(2);
if (id > 0)
{
data = await _infoService.DetailAsync(id);
}
}
}
}