public IHttpActionResult Get(int competitionSeasonId) { try { // Get the competition season object to work with var competitionSeason = CompetitionSeasonRepository.Get(competitionSeasonId); // Get all of the players from the competition season var players = PlayerRepository.GetAllByCompetitionSeason(competitionSeasonId); // For each of the players get the completed fixture closed predictions and create a ranking object var rankings = new List <IRanking>(); foreach (var player in players) { player.Predictions = PredictionRepository.GetByCompetitionSeasonPlayer(competitionSeasonId, player.Id); var completedClosedPredictions = player.GetCompletedClosedPredictions(); var liveClosedPredictions = player.GetLiveClosedPredictions(); var combinedPredictions = new List <IClosedPrediction>(); combinedPredictions.AddRange(liveClosedPredictions); combinedPredictions.AddRange(completedClosedPredictions); //combinedPredictions.AddRange(liveClosedPredictions); var ranking = new Ranking(player.User.FullName, combinedPredictions, competitionSeason); rankings.Add(ranking); } Ranking.OrderRankings(rankings); return(Ok(rankings)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult Get(int competitionSeasonId, int playerId) { try { var player = PlayerRepository.Get(playerId); var predictions = PredictionRepository.GetByCompetitionSeasonPlayer(competitionSeasonId, playerId); player.Predictions = predictions; return(Ok(player)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult Get(int competitionSeasonId, int playerId) { try { var player = PlayerRepository.Get(playerId); player.Predictions = PredictionRepository.GetByCompetitionSeasonPlayer(competitionSeasonId, playerId); var closedPredictions = player.GetLiveClosedPredictions(); // Get the points scored for each of the predictions var competitionSeason = CompetitionSeasonRepository.Get(competitionSeasonId); return(Ok(closedPredictions)); } catch (Exception ex) { return(InternalServerError(ex)); } }