public Response AddEventReview(NewEventReviewRequest request) { var validationResult = newEventReviewValidator.Validate(request); if (!validationResult.IsValid) { return(Response.CreateResponse(validationResult.Messages)); } var club = clubQuery.GetClub(request.ClubId); if (club == null) { return(Response.CreateResponse(new EntityNotFoundException("The specified club does not exist"))); } var @event = eventQuery.GetEvent(request.EventId); if (@event == null) { return(Response.CreateResponse(new EntityNotFoundException("The specified event does not exist"))); } else if (@event.ClubId != request.ClubId) { return(Response.CreateResponse(new IllegalOperationException("The specified event does not belong to this club"))); } var coach = memberQuery.GetCoach(request.CoachId); if (coach == null) { return(Response.CreateResponse(new EntityNotFoundException("The specified event does not exist"))); } else if (coach.ClubId != request.ClubId) { return(Response.CreateResponse(new IllegalOperationException("The specified coach does not belong to this club"))); } var unreviewedSquads = eventQuery.GetUnReviewedSquads(request.EventId); if (request.Squads.Except(unreviewedSquads.Select(s => s.Guid)).Any()) { return(Response.CreateResponse(new IllegalOperationException("The specified squads are not associated with this event"))); } try { eventRepository.AddEventReview(request); return(Response.CreateSuccessResponse()); } catch (Exception ex) { return(Response.CreateResponse(ex)); } }