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); }
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); }
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); }
public ActionResult BizUnitNew(int branchId) { BizUnitViewModel vm = new BizUnitViewModel(); vm.Branch = db.Branches.Single(p => p.BranchId == branchId); return View(vm); }
public ActionResult BizUnitEdit(int id) { BizUnitViewModel vm = new BizUnitViewModel(); vm.BizUnit = db.BizUnits.Include("Branch").Single(p => p.BizUnitId == id); return View(vm); }