public ActionResult Edit(Guid id) { User tUser = db.Users.Find(id); if (tUser != null) { EditUserModel user = new EditUserModel { UserId = id, Username = tUser.Username, Email = tUser.Email, IsApproved = tUser.IsApproved, ExtraField = tUser.ExtraField }; return View(user); } return View(new EditUserModel()); }
public ActionResult Edit(EditUserModel user) { if (ModelState.IsValid) { Entities.User usr = db.Users.Find(user.UserId); usr.ExtraField = user.ExtraField; usr.Email = user.Email; usr.Username = user.Username; usr.IsApproved = user.IsApproved; db.SaveChanges(); return RedirectToAction("Index"); } return View(user); }