public Response AddAvailability(NewAvailabilityRequest request) { var validationResult = newAvailabilityValidator.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 player = memberQuery.GetPlayer(request.PlayerId); if (player == null) { return(Response.CreateResponse(new EntityNotFoundException("The specified player does not exist"))); } var squad = squadQuery.GetSquad(player.SquadId); if (squad == null || squad.ClubId != club.Guid) { return(Response.CreateResponse(new IllegalOperationException("The specified player does not belong to this club"))); } try { repository.AddAvailability(request); return(Response.CreateSuccessResponse()); } catch (Exception ex) { return(Response.CreateResponse(ex)); } }