Exemple #1
0
 public ActionResult SubDeptNew(SubDeptViewModel vm, int deptId)
 {
     if (ModelState.IsValid)
     {
         vm.SubDept.DeptId = deptId;
         db.SubDepts.AddObject(vm.SubDept);
         db.SaveChanges();
         return RedirectToAction("SubDeptList", new { deptId = deptId });
     }
     vm.Dept = db.Depts.Single(p => p.DeptId == deptId);
     return View(vm);
 }
Exemple #2
0
 public ActionResult SubDeptNew(int deptId)
 {
     SubDeptViewModel vm = new SubDeptViewModel();
     vm.Dept = db.Depts.Single(p => p.DeptId == deptId);
     return View(vm);
 }
Exemple #3
0
 public ActionResult SubDeptEdit(SubDeptViewModel vm, int id)
 {
     if (ModelState.IsValid)
     {
         db.SubDepts.Attach(vm.SubDept);
         db.ObjectStateManager.ChangeObjectState(vm.SubDept, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("SubDeptList", new { deptId = vm.SubDept.DeptId });
     }
     return View(vm);
 }
Exemple #4
0
 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);
 }
Exemple #5
0
 public ActionResult SubDeptEdit(int id)
 {
     SubDeptViewModel vm = new SubDeptViewModel();
     vm.SubDept = db.SubDepts.Single(p => p.SubDeptId == id);
     return View(vm);
 }