Пример #1
0
        public ActionResult SubDeptDelete(int id)
        {
            SubDeptViewModel vm = new SubDeptViewModel();

            vm.SubDept = db.SubDepts.Single(p => p.SubDeptId == id);
            return(View(vm));
        }
Пример #2
0
        public ActionResult SubDeptNew(int deptId)
        {
            SubDeptViewModel vm = new SubDeptViewModel();

            vm.Dept = db.Depts.Single(p => p.DeptId == deptId);
            return(View(vm));
        }
Пример #3
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));
        }
Пример #4
0
 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));
 }
Пример #5
0
 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));
 }