public async Task <ProfileDto> UpdateProfileAsync(ProfileUpsertDto profile) { var profileToUpdate = mapper.Map <DomainModels.Profile>(profile); var updatedProfile = await profileRepository.UpdateAsync(profileToUpdate); return(mapper.Map <ProfileDto>(updatedProfile)); }
public async Task <ProfileDto> UpdateProfileAsync(ProfileUpsertDto profile) { var profileToUpdate = await profileRepository.GetOrDefaultAsync(profile.Id); if (profileToUpdate == null) { throw new NotFoundException("No profile found with this id"); } profileToUpdate.ImagePath = profile.ImagePath; profileToUpdate.DisplayName = profile.DisplayName; var updatedProfile = await profileRepository.UpdateAsync(profileToUpdate); var profileDto = mapper.Map <ProfileDto>(updatedProfile); return(profileDto); }
public async Task <ActionResult <ProfileDto> > UpdateAsync([FromRoute] string id, [FromBody] ProfileUpsertDto profile) { if (id != profile.Id) { return(BadRequest("Request id and profile id must be same")); } var updatedProfile = await profileService.UpdateProfileAsync(profile); return(Ok(updatedProfile)); }
public async Task <ActionResult <ProfileDto> > CreateAsync([FromBody] ProfileUpsertDto profile) { var createdProfile = await profileService.CreateProfileAsync(profile); return(Created("", createdProfile)); }
public async Task <ActionResult <ProfileDto> > UpdateAsync([FromRoute] string id, [FromBody] ProfileUpsertDto profile) { if (id != profile.Id) { return(BadRequest("Profile Id didn't matched with route Id")); } var updatedProfile = await profileService.UpdateProfileAsync(profile); return(Ok(updatedProfile)); }
public async Task <ActionResult <ProfileDto> > CreateAsync([FromBody] ProfileUpsertDto profile) { var createdProfile = await profileService.CreateProfileAsync(profile); return(Created($"/api/users/${createdProfile.UserId}/profile", createdProfile)); }