public ActionResult UpdateProfile(UpdateProfileDTO userDto, HttpPostedFileBase image) { var user = UserManager.FindById(User.Identity.GetUserId()); if (!ModelState.IsValid) { userDto.Image = user.Image; return(View(userDto)); } if (image != null) { userDto.Image = Path.Combine(@"\Assets\images\useravatars\", $"user_{user.Id}" + Path.GetExtension(image.FileName)); string path = Path.Combine(Server.MapPath(@"~\Assets\images\useravatars\"), $"user_{user.Id}" + Path.GetExtension(image.FileName)); image.SaveAs(path); } else { userDto.Image = user.Image; } user = _mapper.Map(userDto, user); UserManager.Update(user); return(RedirectToAction("profile")); }
public ActionResult <Data.Models.Profile> Put([FromBody] UpdateProfileDTO request) { var command = new EditProfileCommand(_mapper.Map <Data.Models.Profile>(request)); var handler = _commandHandler.Build(command); return(Ok(handler.Execute())); }
public void UpdateProfile(UpdateProfileDTO updatedProfile) { var updatedUser = db.Users.FirstOrDefault(u => u.UserId == updatedProfile.UserId); updatedUser.Phone = updatedProfile.Phone; updatedUser.FullName = updatedProfile.FullName; updatedUser.Picture = updatedProfile.ProfilePictureAsString; Db.SaveChanges(); }
public IHttpActionResult UpdateProfile(UpdateProfileDTO updatedProfile) { try { service.UpdateProfile(updatedProfile); return(Ok()); } catch (Exception e) { return(InternalServerError(e)); } }
public async Task <IActionResult> Update(UpdateProfileDTO updateProfileDTO) { if (!User.Identity.IsAuthenticated) { return(Unauthorized("You need to be logged in to perform this action")); } var validation = _updateProfileValidator.Validate(updateProfileDTO); if (!validation.IsValid) { return(BadRequest(validation)); } string mailAdress = User.Identity.Name; if (mailAdress == null) { return(BadRequest("User not found")); } var user = _userRepository.GetBy(mailAdress); var identityUser = await _userManager.FindByNameAsync(mailAdress); if (user == null || identityUser == null) { return(BadRequest("User not found")); } // Update User updateProfileDTO.UpdateUser(ref user); _userRepository.Update(user); // Update IdentityUser updateProfileDTO.UpdateIdentityUser(ref identityUser); var result = await _userManager.UpdateAsync(identityUser); if (!result.Succeeded) { return(BadRequest("Unable to update the user, internal error")); } return(Ok(user)); }
public ActionResult UpdateInfo(UpdateProfileDTO updateProfileDTO) { var user = UserManager.FindById(User.Identity.GetUserId()); if (!ModelState.IsValid) { return(View(updateProfileDTO)); } var image = user.Image; user = _mapper.Map(updateProfileDTO, user); user.Image = image; UserManager.Update(user); TempData["SaveSuccess"] = "true"; return(RedirectToAction("info")); }
public async Task <ActionResult> UpdateProfile(UpdateProfileDTO updateProfileDTO) { ShopModel shop = await userCosmosDBService.GetUserInfo(updateProfileDTO.UserEmail); mapper.Map(updateProfileDTO, shop, typeof(UpdateProfileDTO), typeof(ShopModel)); if (!string.IsNullOrWhiteSpace(updateProfileDTO.Password)) { Encryption.CreatePasswordHash(updateProfileDTO.Password, out byte[] passwordHash, out byte[] passwordSalt); shop.PasswordHash = passwordHash; shop.PasswordSalt = passwordSalt; } if (await userCosmosDBService.ReplaceDocumentAsync(shop.SelfLink, shop)) { return(Ok("Successfully updated the profile of the user")); } return(BadRequest("Something Went Wrong!")); }
public void UpdateProfile(UpdateProfileDTO updatedProfile) { this.UserLogic.UpdateProfile(updatedProfile); }