public static IEnumerable<DogPoints> GetDogPointsByRace(int raceid,int teamid) { List<DogPoints> dg = new List<DogPoints>(); foreach (TournamentTeamDog ttd in TournamentTeamDog.List(Convert.ToInt16(Heat.GetTournamentTeamIDbyRaceID(raceid,teamid)))) { DogPoints d = new DogPoints(); d.DogName = Dog.Detail(ttd.DogCRN).DogName; int pts = 0; foreach (Heat h in Heat.GetHeatsDogWasIn(ttd.TournamentTeamDogID,raceid)) { pts = pts + Convert.ToInt16(h.Points); } d.Points = pts; dg.Add(d); } var oDogPoints = (from dogPoints in dg orderby dogPoints.Points descending, dogPoints.DogName select dogPoints); return oDogPoints.ToList(); }
public static List<DogPoints> PointsByTeamID(int teamid) { List<DogPoints> points = new List<DogPoints>(); foreach (TournamentTeamDog ttd in TournamentTeamDog.List(teamid)) { DogPoints dog = new DogPoints(); dog.DogName = Dog.Detail(ttd.DogCRN).DogName; int pts=0; foreach (Heat heat in Heat.GetHeatsDogWasIn(ttd.TournamentTeamDogID)) { pts = pts + Convert.ToInt16(heat.Points); } dog.Points = pts; points.Add(dog); } var ordered = (from p in points orderby p.Points descending, p.DogName select p); return ordered.ToList(); }