/// <summary> /// Updates existing Department /// </summary> /// <param name="_dept">Accept Instance of Department</param> public void UpdateDepartment(Department _dept) { if (_dept == null) { throw new ArgumentNullException("dept"); } _context.Entry <Department>(_dept).State = EntityState.Modified; _context.SaveChangesAsync(); }
/// <summary> /// Updates Account /// </summary> /// <param name="account">Account to be Updated</param> /// <returns>True if Account is Updated Successfully, False otherwise i.e (When Duplicate Account Number)</returns> /// <exception cref="">ArgumentNUllException if account is NULL</exception> public async Task <bool> UpdateAccount(Account account) { if (account == null) { throw new ArgumentNullException("account"); } if (!UniqueAccount(account)) { return(false); } _context.Entry <Account>(account).State = System.Data.Entity.EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <ActionResult> Edit(EditUserViewModel model) { if (ModelState.IsValid) { var Db = new ApricotContext(); var user = Db.Users.First(u => u.UserName == model.UserName); // Update the user data: user.FirstName = model.FirstName; user.LastName = model.LastName; user.Email = model.Email; Db.Entry(user).State = System.Data.Entity.EntityState.Modified; await Db.SaveChangesAsync(); return(RedirectToAction("Index")); } // If we got this far, something failed, redisplay form return(View(model)); }
/// <summary> /// Update Employee /// </summary> /// <param name="employee">Employee to Update</param> /// <returns>True is Employee is Update Successfully, False Otherwise (i.e. Duplicate Employee Number)</returns> /// <exception cref="">ArgumentNullException if employee is NULL</exception> public bool UpdateEmployee(Employee employee) { if (employee == null) { throw new ArgumentNullException("employee"); } if (!UniqueEmployee(employee)) { return(false); } _context.Entry <Employee>(employee).State = EntityState.Modified; _context.SaveChangesAsync(); return(true); }