public IActionResult Index(Guid CourseId) { try { var course = _courseAccessLayer.GetCourse(CourseId); var highestPossibleScore = course.Par + 50; var lowestPossibleScore = course.Par - 10; var players = _playerAccessLayer.GetAllPlayers(); var rounds = _golfRoundAccessLayer.GetAllGolfRounds().Where(r => r.CourseId.Equals(CourseId)); IList <Forecast> forecasts = new List <Forecast>(); foreach (var player in players) { var playerScores = _scoreAccessLayer.GetAllPlayerScores(player.Id); IEnumerable <int> playerScoresForCourse = playerScores.Join(rounds, score => score.GolfRoundId, round => round.Id, (score, round) => score.Value); if (playerScoresForCourse.Count() == 0) { playerScoresForCourse = playerScores.Select(s => s.Value); } var playerForecast = forecast(player, playerScoresForCourse, course, lowestPossibleScore, highestPossibleScore); forecasts.Add(playerForecast); } return(Ok(forecasts)); } catch { return(BadRequest()); } }
public IActionResult GetAllPlayerRoundCourses(Guid PlayerId) { var rounds = _scoreAccessLayer.GetAllPlayerScores(PlayerId); var courses = _golfRoundAccessLayer.GetAllGolfRoundCourseIds(rounds.Select(s => s.GolfRoundId).ToList()); return(Ok(_courseAccessLayer.GetCourseStats(courses.ToList()))); }