public ActionResult SubDeptDelete(int id) { SubDeptViewModel vm = new SubDeptViewModel(); vm.SubDept = db.SubDepts.Single(p => p.SubDeptId == id); return(View(vm)); }
public ActionResult SubDeptNew(int deptId) { SubDeptViewModel vm = new SubDeptViewModel(); vm.Dept = db.Depts.Single(p => p.DeptId == deptId); return(View(vm)); }
public ActionResult SubDeptList(int deptId) { SubDeptViewModel vm = new SubDeptViewModel(); vm.Dept = db.Depts.Single(p => p.DeptId == deptId); vm.SubDepts = db.SubDepts.Where(p => p.DeptId == deptId); ViewBag.CanModify = userData.IsAdmin; return(View(vm)); }
public ActionResult SubDeptEdit(SubDeptViewModel vm, int id) { if (ModelState.IsValid) { db.SubDepts.Attach(vm.SubDept); db.Entry(vm.SubDept).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("SubDeptList", new { deptId = vm.SubDept.DeptId })); } return(View(vm)); }
public ActionResult SubDeptNew(SubDeptViewModel vm, int deptId) { if (ModelState.IsValid) { vm.SubDept.DeptId = deptId; db.SubDepts.Add(vm.SubDept); db.SaveChanges(); return(RedirectToAction("SubDeptList", new { deptId = deptId })); } vm.Dept = db.Depts.Single(p => p.DeptId == deptId); return(View(vm)); }