Пример #1
0
 public ActionResult BizUnitList(int branchId)
 {
     BizUnitViewModel vm = new BizUnitViewModel();
     vm.BizUnits = db.BizUnits.Where(p => p.BranchId == branchId);
     vm.Branch = db.Branches.Single(p => p.BranchId == branchId);
     ViewBag.CanModify = userData.IsAdmin;
     return View(vm);
 }
Пример #2
0
 public ActionResult BizUnitNew(BizUnitViewModel vm, int branchId)
 {
     if (ModelState.IsValid)
     {
         vm.BizUnit.BranchId = branchId;
         db.BizUnits.AddObject(vm.BizUnit);
         db.SaveChanges();
         return RedirectToAction("BizUnitList", new { branchId = branchId });
     }
     vm.Branch = db.Branches.Single(p => p.BranchId == branchId);
     return View(vm);
 }
Пример #3
0
 public ActionResult BizUnitEdit(BizUnit bizUnit)
 {
     if (ModelState.IsValid)
     {
         db.BizUnits.Attach(bizUnit);
         db.ObjectStateManager.ChangeObjectState(bizUnit, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("BizUnitList", new { branchId = bizUnit.BranchId });
     }
     BizUnitViewModel vm = new BizUnitViewModel();
     vm.BizUnit = bizUnit;
     return View(vm);
 }
Пример #4
0
 public ActionResult BizUnitNew(int branchId)
 {
     BizUnitViewModel vm = new BizUnitViewModel();
     vm.Branch = db.Branches.Single(p => p.BranchId == branchId);
     return View(vm);
 }
Пример #5
0
 public ActionResult BizUnitEdit(int id)
 {
     BizUnitViewModel vm = new BizUnitViewModel();
     vm.BizUnit = db.BizUnits.Include("Branch").Single(p => p.BizUnitId == id);
     return View(vm);
 }