예제 #1
0
        public async Task <JsonResult> GetLeaders(DateTime fromDate)
        {
            var bountiesFrom = await _bountyRepository.GetBountiesFrom(fromDate);

            var bountiesBySquad = bountiesFrom.GroupBy(i => i.SquadName).ToList();
            var squadData       = await _squadRepository.GetSquadData(bountiesBySquad.Select(i => i.Key).ToList());


            var leaders = (from b in bountiesBySquad
                           join s in squadData on b.Key equals s.SquadName
                           select
                           new Leader()
            {
                AllTimeScore = 2000,
                SquadName = s.SquadName,
                SquadImage = s.SquadImage,
                TimeWindowScore = b.Sum(i => i.Value)
            }).OrderByDescending(i => i.TimeWindowScore);

            return(Json(leaders));
        }