public static User UpdateUser(QuizUserViewModel updatedUser) { using (QuizBuilderDb db = new QuizBuilderDb()) { User currentUser = UserService.FindByName(updatedUser.UserName); if (currentUser != null) { currentUser = db.Users.Find(currentUser.UserID); currentUser.FirstName = updatedUser.FirstName; currentUser.LastName = updatedUser.LastName; currentUser.Email = updatedUser.EmailAddress; db.SaveChanges(); return currentUser; } else { return currentUser; } } }
public ActionResult UpdateUser(QuizUserViewModel model) { if (ModelState.IsValid) { UserService.UpdateUser(model); return RedirectToAction("Default"); } else { return View("Default", model); } }