using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; 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.Menu { public class EditButtonModel : BaseModel { public YB_nMenuAction data = new YB_nMenuAction(); public List list = new List(); public List types = new List(); private ISystemService _systemService; public EditButtonModel(ISystemService systemService) { _systemService = systemService; } public async Task OnGetAsync(Guid? id) { types = EnumHelper.GetEnumDictionary().Select(x => new SelectListItem { Value = x.Key.ToString(), Text = x.Value }).ToList(); var menu = await _systemService.GetMenuListAsync(); var treeList = new List(); foreach (var item in menu) { TreeSelectModel treeModel = new TreeSelectModel(); treeModel.id = item.Id + ""; treeModel.text = item.Name; treeModel.parentId = item.ParentId + ""; treeModel.data = item; treeList.Add(treeModel); } list = treeList.TreeSelectGuidJson().ToObject>(); if (id.HasValue && id.Value != Guid.Empty) { data = await _systemService.GetActionDetailAsync(id.Value); } } } }