public async Task<IActionResult> Edit(int id, [Bind("DepName,Pid,Guid,PGuid,Id,CreateTime,IsDelete,Description,TimestampV")] AdmDepartment admDepartment) { if (id != admDepartment.Id) { return NotFound(); } if (ModelState.IsValid) { try { _context.Update(admDepartment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdmDepartmentExists(admDepartment.Id)) { return NotFound(); } else { throw; } } return RedirectToAction(nameof(Index)); } return View(admDepartment); }
public void GetRootNodes(List<AdmDepartment> admDepartments, AdmDepartment admDepartment) { try { if (admDepartments.Count > 0) { if (admDepartments.Count > 0) { var menu = admDepartments.FirstOrDefault(u => u.Guid == admDepartment.PGuid); if (menu != null && menu.Id > 0) { GetRootNodes(admDepartments, menu); } else { if (!RootDepGuidList.Contains(admDepartment.Guid)) { RootDepGuidList.Add(admDepartment.Guid); RootDeps.Add(admDepartment); } } } } } catch (Exception) { throw; } }
public async Task<IActionResult> Create([Bind("DepName,Pid,Guid,PGuid,Id,CreateTime,IsDelete,Description,TimestampV")] AdmDepartment admDepartment) { if (ModelState.IsValid) { admDepartment.CreateTime = DateTime.Now; admDepartment.Guid = Guid.NewGuid().ToString().ToUpper(); _context.Add(admDepartment); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(admDepartment); }
public AdmDepartment CreateNodeTree(List<AdmDepartment> admDepartments, AdmDepartment admDepartment) { if (admDepartments.Count > 0) { List<AdmDepartment> listm = admDepartments.Where(u => u.PGuid == admDepartment.Guid).ToList(); if (listm != null && listm.Count > 0) { admDepartment.Children = listm; listm.ForEach(m => { CreateNodeTree(admDepartments, m); }); } } return admDepartment; }