/// <summary> /// Get League Scoring Breakdown by season week id /// </summary> /// <param name="seasonWeekId">The season week id representing the season week.</param> public IEnumerable<OwnerPoints> GetLeaguePoints(int seasonWeekId) { List<OwnerPoints> ownerPoints = new List<OwnerPoints>(); foreach (var owner in context.Owners) { OwnerPoints ownerPoint = new OwnerPoints { OwnerId = owner.OwnerId, OwnerName = owner.OwnerName, TeamName = owner.TeamName, UniqueId = owner.UniqueId, SeasonWeekId = seasonWeekId, TotalPoints = 0 }; ownerPoints.Add(ownerPoint); } var query = NPGGFFLApi.queries.LeaguePointsQuery; query = query.Replace("{{:PlayerPointsQuery}}", NPGGFFLApi.queries.PlayerPointsQuery); query = query.Replace("{{:GameFilter}}", string.Empty); query = query.Replace("{{:PlayerFilter}}", string.Empty); query = query.Replace("{{:OwnerFilter}}", string.Empty); query = query.Replace("{{:SeasonWeekFilter}}", string.Format("and pp.SeasonWeekId = {0}", seasonWeekId)); var leaguePointsThisWeek = context.ExecuteQuery<OwnerPoints>(query); foreach (var pptw in leaguePointsThisWeek) { var ownerPointExists = ownerPoints.Where(op => op.OwnerId == pptw.OwnerId).FirstOrDefault(); if (ownerPointExists != null) { ownerPointExists.TotalPoints = Math.Round(pptw.TotalPoints, 2); } } return ownerPoints.OrderByDescending(op => op.TotalPoints).ThenBy(op => op.OwnerName); }
public OwnerPoints GetLeaguePoints(string uniqueId, int seasonWeekId) { List<OwnerPoints> ownerPoints = new List<OwnerPoints>(); var owner = context.Owners.Where(o => o.UniqueId == uniqueId).First(); OwnerPoints ownerPoint = new OwnerPoints { OwnerId = owner.OwnerId, OwnerName = owner.OwnerName, TeamName = owner.TeamName, UniqueId = owner.UniqueId, SeasonWeekId = seasonWeekId, TotalPoints = 0 }; var query = NPGGFFLApi.queries.LeaguePointsQuery; query = query.Replace("{{:PlayerPointsQuery}}", NPGGFFLApi.queries.PlayerPointsQuery); query = query.Replace("{{:GameFilter}}", string.Empty); query = query.Replace("{{:PlayerFilter}}", string.Empty); query = query.Replace("{{:OwnerFilter}}", string.Format("and o.OwnerId = {0}", owner.OwnerId)); query = query.Replace("{{:SeasonWeekFilter}}", string.Format("and pp.SeasonWeekId = {0}", seasonWeekId)); var ownerPointsForWeek = context.ExecuteQuery<OwnerPoints>(query).FirstOrDefault(); if (ownerPointsForWeek != null) { ownerPoint.TotalPoints = Math.Round(ownerPointsForWeek.TotalPoints, 2); } return ownerPoint; }