public async Task UpdateProfile(UserProfileInputModel input, ImageUploadResult imageInput = null) { var user = this.userRepository.All().FirstOrDefault(x => x.Id == input.Id); if (imageInput != null && input.ProfilePicture != null) { await this.imagesService.CreateProfileImage(input.Id, imageInput); } if (input.Camera != null) { user.Camera = input.Camera; } if (input.LivesIn != null) { user.LivesIn = input.LivesIn; } if (input.Name != null) { user.Name = input.Name; } if (input.Proffesion != null) { user.Proffesion = input.Proffesion; } await this.userRepository.SaveChangesAsync(); }
public ActionResult Edit(UserProfileInputModel userProfileInput, HttpPostedFileBase image) { if (ModelState.IsValid) { if (image != null) { userProfileInput.ImageMimeType = image.ContentType; userProfileInput.ImageData = new byte[image.ContentLength]; image.InputStream.Read(userProfileInput.ImageData, 0, image.ContentLength); } userProfileInput.Id = _userService.GetUserEntityByLogin(User.Identity.Name).Id; var profileEntity = userProfileInput.ToBllProfile(); if (_profileService.GetProfileEntity(profileEntity.Id) == null) { _profileService.CreateProfile(profileEntity); } else { _profileService.UpdateProfile(profileEntity); } return(RedirectToAction("Index")); } else { return(RedirectToAction("NotFound", "Error")); } }
public static ProfileEntity ToBllProfile(this UserProfileInputModel profile) { return(new ProfileEntity { Id = profile.Id, ImageData = profile.ImageData, ImageMimeType = profile.ImageMimeType }); }
[HttpPut("profile/{userId}")] //1220 public async Task <ActionResult> UpdateStudentProfileByUserId([FromBody] UserProfileInputModel inputModel, int userId) { if (inputModel.Id == userId) { await userStorage.UpdateStudentProfile(UserProfileMapper.ToDataModel(inputModel)); } else { return(BadRequest("Not enough rights!")); } return(Ok()); }
public static User ToDataModel(UserProfileInputModel inputModel) { User user = new User { Id = inputModel.Id, FirstName = inputModel.FirstName, LastName = inputModel.LastName, Patronymic = inputModel.Patronymic, BirthDate = Convert.ToDateTime(inputModel.BirthDate), Email = inputModel.Email, Phone = inputModel.Phone, Photo = inputModel.Photo }; return(user); }
public ActionResult Index() { var userProfileinput = new UserProfileInputModel(); userProfileinput.Id = _userService.GetUserEntityByLogin(User.Identity.Name).Id; var profileEntity = _profileService.GetProfileEntity(userProfileinput.Id); if (profileEntity != null) { userProfileinput.ImageData = profileEntity.ImageData; userProfileinput.ImageMimeType = profileEntity.ImageMimeType; } return(View(userProfileinput)); }
public async Task <IActionResult> UpdateProfile(UserProfileInputModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } if (input.ProfilePicture != null) { var imageInfo = await CloudinaryExtension.UploadImageAsync(this.cloudinary, input.ProfilePicture); await this.userService.UpdateProfile(input, imageInfo); } else { await this.userService.UpdateProfile(input); } return(this.RedirectToAction(nameof(this.Profile), new { username = "******" })); }
public async Task <AppHttpResponseMessageWrapper> SaveInfoAsync(UserProfileInputModel profileInfo) { var resonce = await _httpClient.PostAsJsonAsync("api/profile/save", profileInfo); return(new AppHttpResponseMessageWrapper(resonce)); }