Ejemplo n.º 1
0
        public async Task <CommunityViewModel> UpdateCommunityImageAsync(Community community,
                                                                         UpdateCommunityImageDto updateCommunityImageDto)
        {
            community.Image = updateCommunityImageDto.Image;

            await _communityRepository.UpdateAsync(community);

            return(_mapper.Map <CommunityViewModel>(community));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UpdateImage([FromRoute] string communityId,
                                                      [FromBody] UpdateCommunityImageDto updateCommunityImageDto)
        {
            Community community = await _mediator.Send(new GetCommunityEntityQuery(communityId));

            AuthorizationResult authorizationResult =
                await _authorizationService.AuthorizeAsync(User, community,
                                                           PolicyConstants.UpdateCommunityRolePolicy);

            if (!authorizationResult.Succeeded)
            {
                return(ActionResults.UnauthorizedResult(User.Identity.IsAuthenticated));
            }

            return(Ok(new Response <CommunityViewModel>
            {
                Data = await _mediator.Send(new UpdateCommunityImageCommand(community, updateCommunityImageDto)),
            }));
        }
 public UpdateCommunityImageCommand(Domain.Entities.Community community,
                                    UpdateCommunityImageDto updateCommunityImageDto)
 {
     Community = community;
     UpdateCommunityImageDto = updateCommunityImageDto;
 }