public ActionResult Edit(UserProfileModel model) { if (ModelState.IsValid) { var user = UserManager.FindById(model.UserId); user.Email = model.Email; user.FirstName = model.FirstName; user.LastName = model.LastName; user.SendEmail = model.SendEmail; user.SendName = model.SendName; UserManager.Update(user); UpdateUserRole(user.Id, UserRoles.StudentRole, model.IsStudent); UpdateUserRole(user.Id, UserRoles.TeacherRole, model.IsTeacher); if (User.Identity.GetUserId() == user.Id) { var claimsIdentity = UserManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); Request.GetOwinContext().Authentication.SignIn(claimsIdentity); } return RedirectToAction("Index", "Home"); } return View(model); }
// // GET: /User/Edit/5 public ActionResult Edit(string id) { if (string.IsNullOrEmpty(id)) { id = User.Identity.GetUserId(); } var user = UserManager.FindById(id); var model = new UserProfileModel(user); model.IsStudent = UserManager.IsInRole(user.Id, UserRoles.StudentRole); model.IsTeacher = UserManager.IsInRole(user.Id, UserRoles.TeacherRole); return View(model); }