public async Task OnGetAsync(long?id, long?pid) { if (id.HasValue) { //编辑 Dto = await _service.GetByIdAsync(id.Value); if (Dto == null) { throw new KuDataNotFoundException("无法取得数据!"); } if (Dto.ParentId.HasValue) { Parents = await _service.GetParentsAsync(Dto.ParentId.Value); } ViewData["Mode"] = "Edit"; } else { //新增 Dto = new ColumnDto(); if (pid.HasValue) { Dto.ParentId = pid.Value; Parents = await _service.GetParentsAsync(pid.Value); } else { Dto.ParentId = null; } ViewData["Mode"] = "Add"; } }
public async Task OnGetAsync(long?parentId) { Parents = new List <ColumnDto>(); if (parentId.HasValue) { Parents = await _service.GetParentsAsync(parentId.Value); } ViewData["ParentId"] = parentId; }