public void EditProfileFromBm(EditProfileBm model, User user) { var currentUser = this.data.Context.Users.Find(user.Id); currentUser.Email = model.Email; currentUser.Phone = model.Phone; currentUser.Password = model.NewPassword; this.data.Context.SaveChanges(); }
public ActionResult Edit([Bind(Exclude = "")] EditProfileBm model) { var httpCookie = this.Request.Cookies.Get("sessionId"); if (httpCookie == null || !AuthenticationManager.IsAuthenticated(httpCookie.Value)) { return(this.RedirectToAction("Login")); } var user = AuthenticationManager.GetUser(httpCookie.Value); ViewBag.Username = user.Username; if (this.ModelState.IsValid && user.Password == model.CurrentPassword) { this.service.EditProfileFromBm(model, user); return(this.RedirectToAction("Profile", new { username = $"{user.Username}" })); } var viewModel = this.service.GetEditProfileVm(user); return(this.View(viewModel)); }