public async Task ReviewPetition(ReviewPetitionRequest reviewPetitionRequest, CancellationToken cancellationToken) { var petition = await _petitionRepository.FindById(reviewPetitionRequest.Id, cancellationToken); if (petition == null) { throw new PetitionNotFoundException(reviewPetitionRequest.Id); } petition.Reviewed = true; petition.DecisionEnum = reviewPetitionRequest.DecisionEnum; petition.ReviewResult = reviewPetitionRequest.Text; switch (petition.DecisionEnum) { case DecisionEnum.BanAd: var petitionsToResole = await _petitionRepository .FindWhere(x => x.AdId == petition.AdId && !x.Reviewed, cancellationToken); foreach (var pet in petitionsToResole) { pet.Reviewed = true; pet.DecisionEnum = reviewPetitionRequest.DecisionEnum; pet.ReviewResult = reviewPetitionRequest.Text; await _petitionRepository.Save(pet, cancellationToken); } await _adService.UpdateAdStatus(petition.AdId, Statuses.Rejected, petition.ReviewResult, cancellationToken); break; case DecisionEnum.BanUser: var petitions = await _petitionRepository .FindWhere(x => x.AdId == petition.AdId && !x.Reviewed, cancellationToken); foreach (var pet in petitions) { pet.Reviewed = true; pet.DecisionEnum = reviewPetitionRequest.DecisionEnum; pet.ReviewResult = reviewPetitionRequest.Text; await _petitionRepository.Save(pet, cancellationToken); } await _adService.RejectAllAdsOfUser(petition.Ad.OwnerId, petition.ReviewResult, cancellationToken); break; default: break; } await _petitionRepository.Save(petition, cancellationToken); }