public async Task <IActionResult> EditProfile(EditProfileVm model) { if (!ModelState.IsValid) { return(View(model)); } var user = await userManager.GetUserAsync(User); user.FullName = model.FullName; user.UserName = model.Email; user.Email = model.Email; var result = await userManager.UpdateAsync(user); if (result.Succeeded) { TempData["Success"] = "Profile was updated successfully."; return(View("EditProfileSuccess")); } else { foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } return(View(model)); } }
public ApiResult UpdateProfile(EditProfileVm model) { var profile = _mapper.Map <ProfileDto>(model); _profileService.UpdateProfile(model.UserName, profile); return(ApiResult.Ok); }
public EditProfileVm RetrieveEditProfileVm(string username) { ApplicationUser appUser = this.DbContext.Users .First(user => user.UserName == username); EditProfileVm editProfileVm = Mapper.Map <EditProfileVm>(appUser); return(editProfileVm); }
public async Task <IActionResult> EditProfile() { var user = await userManager.GetUserAsync(User); EditProfileVm model = new EditProfileVm { FullName = user.FullName, Email = user.Email }; return(View(model)); }
public async Task SaveUserProfile(EditProfileVm userProfileVm) { var q = @"UPDATE [User] SET FirstName=@name WHERE ID=@userId"; using (var con = new SqlConnection(ConnectionString)) { con.Open(); await con.ExecuteAsync(q, new { @userId = userProfileVm.Id, @name = userProfileVm.Name }); } }
public EditProfileVm GetEditProfileVm(User user) { var vm = new EditProfileVm(); var currentUser = this.data.Context.Users.Find(user.Id); vm.Email = user.Email; vm.Phone = user.Phone; return(vm); }
public ActionResult EditProfile(string username) { if (username != this.HttpContext.User.Identity.Name) { return(this.Redirect("/Home/Index")); } EditProfileVm editProfileVm = this.service.RetrieveEditProfileVm(username); return(this.View(editProfileVm)); }
public async Task <EditProfileVm> GetUserProfile() { var vm = new EditProfileVm(); var user = await this.userRepository.GetUser(this.userSessionHelper.UserId); if (user != null) { vm.Name = user.Name; vm.Email = user.EmailAddress; } return(vm); }
public async Task <ActionResult> EditProfile(EditProfileVm model) { if (ModelState.IsValid) { await _userAccountManager.UpdateProfile(model); SetMessage(MessageType.Success, "Profile updated successfully"); return(RedirectToAction("Index", "Settings")); } //TO DO : Redirect to the Tab ? return(RedirectToAction("Index")); }
public ActionResult EditProfile(EditProfileVm model) { if (ModelState.IsValid) { userAccountManager.UpdateProfile(model); var msg = new AlertMessageStore(); msg.AddMessage("success", "Profile updated successfully"); TempData["AlertMessages"] = msg; return(RedirectToAction("Index", "Settings")); } //TO DO : Redirect to the Tab ? return(RedirectToAction("Index")); }
public ActionResult EditProfile([Bind(Include = "Email,Password,PhoneNumber,NewPassword,UserName")] EditProfileVm vm) { ApplicationUserManager userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>(); if (this.ModelState.IsValid) { ApplicationUser appUser = this.service.GetCurrentUser(this.User.Identity.Name); userManager.ChangePassword(appUser.Id, vm.Password, vm.NewPassword); this.service.ChangeEmailAndNumber(vm, appUser); return(this.Redirect("/Home/Index")); } return(this.View()); }
public async Task <ActionResult> EditProfile(EditProfileVm model) { if (ModelState.IsValid) { await userAccountManager.UpdateProfile(model); var tt = new Dictionary <string, string> { { "success", "Profile updated successfully" } }; TempData["AlertMessages"] = tt; return(RedirectToAction("Index", "Settings")); } //TO DO : Redirect to the Tab ? return(RedirectToAction("Index")); }
public async Task UpdateProfile(EditProfileVm model) { model.Id = this.userSessionHelper.UserId; await userRepository.SaveUserProfile(model); }
public void ChangeEmailAndNumber(EditProfileVm vm, ApplicationUser appUser) { appUser.PhoneNumber = vm.PhoneNumber; appUser.Email = vm.Email; this.DbContext.SaveChanges(); }
public void UpdateProfile(EditProfileVm model) { accountRepository.UpdateProfile(new UserAccountDto { Name = model.Name, EmailAddress = model.Email }); }