public async Task <CommunityViewModel> UpdateCommunityImageAsync(Community community, UpdateCommunityImageDto updateCommunityImageDto) { community.Image = updateCommunityImageDto.Image; await _communityRepository.UpdateAsync(community); return(_mapper.Map <CommunityViewModel>(community)); }
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; }