Example #1
0
        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));
        }
Example #2
0
        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);
        }
Example #3
0
        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));
        }
Example #4
0
        public async Task <ActionResult <ProfileDto> > CreateAsync([FromBody] ProfileUpsertDto profile)
        {
            var createdProfile = await profileService.CreateProfileAsync(profile);

            return(Created("", createdProfile));
        }
Example #5
0
        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));
        }
Example #6
0
        public async Task <ActionResult <ProfileDto> > CreateAsync([FromBody] ProfileUpsertDto profile)
        {
            var createdProfile = await profileService.CreateProfileAsync(profile);

            return(Created($"/api/users/${createdProfile.UserId}/profile", createdProfile));
        }