public IActionResult Edit(EmployeeStoreVM esVM) { esRepo.Update(esVM); // go to index action method of the EmployeeStore controller. return(RedirectToAction("Index", "EmployeeStoreVM")); }
public ActionResult Edit(EmployeeStoreVM esVM) { EmployeeStoreVMRepo esRepo = new EmployeeStoreVMRepo(db); esRepo.Update(esVM); // go to index action method of the same controller. return(RedirectToAction("Index")); }
public bool Update(EmployeeStoreVM esVM) { // Updating our ViewModel really requires updates to two separate tables. // Update the 'Store'. StoreRepo storeRepo = new StoreRepo(db); storeRepo.Update(esVM.Branch, esVM.Region); // Update the 'Employee'. EmployeeRepo empRepo = new EmployeeRepo(db); empRepo.Update(esVM.EmployeeID, esVM.FirstName, esVM.LastName); // Error handling could go here and if problems are encountered // 'false' could be returned. // Otherwise if things go well return true. return(true); }
public EmployeeStoreVM Get(int employeeID, string branch) { EmployeeRepo employeeRepo = new EmployeeRepo(db); Employee employee = employeeRepo.Get(employeeID); StoreRepo storeRepo = new StoreRepo(db); Store store = storeRepo.Get(branch); EmployeeStoreVM esVM = new EmployeeStoreVM { EmployeeID = employee.EmployeeId, LastName = employee.LastName, FirstName = employee.FirstName, Branch = store.Branch, BuildingName = store.BuildingName == null ? "" : store.BuildingName, Region = store.Region, // Need condition to handle null UnitNum = store.UnitNum == null ? 0 : (int)store.UnitNum }; return(esVM); }
public IActionResult Edit(int employeeID, string branch) { EmployeeStoreVM esVM = esRepo.Get(employeeID, branch); return(View(esVM)); }