public UpdateCommunityCommand(string communityId, Domain.Entities.Community community, UpdateCommunityDto updateCommunityDto) { CommunityId = communityId; Community = community; UpdateCommunityDto = updateCommunityDto; }
public async Task <CommunityViewModel> UpdateCommunityAsync(Community community, UpdateCommunityDto updateCommunityDto) { community.Name = updateCommunityDto.Name; community.Description = updateCommunityDto.Description; await _communityRepository.UpdateAsync(community); if (updateCommunityDto.CategoryIds.Any()) { await _communityRepository.AddCategoriesToCommunityAsync(community.Id, updateCommunityDto.CategoryIds); } return(_mapper.Map <CommunityViewModel>(community)); }
public async Task <IActionResult> Update([FromRoute] string communityId, [FromBody] UpdateCommunityDto updateCommunityDto) { 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 UpdateCommunityCommand(communityId, community, updateCommunityDto)), })); }