Beispiel #1
0
        public async Task <MatchSet> GetMatchesForPlayer(string gamertag, int start = 0, params Enumeration.GameMode[] gameModes)
        {
            var playerMatches = await _statsRepository.GetMatchesForPlayer(gamertag, start, 10, gameModes);

            var matches = Mapper.Map <MatchSet>(playerMatches);

            foreach (var result in matches.Results)
            {
                result.Teams           = result.Teams.OrderBy(t => t.Rank).ToList();
                result.PlayerTeamColor = result.Teams.Where(t => t.Id == result.Player.TeamId).Select(t => t.TeamColor).FirstOrDefault();
            }
            await _db.CommitChanges();

            return(matches);
        }
        private async Task Populate <T, T2>(IQuery <List <T2> > query, Func <T2, T> func, bool force = false) where T : class
        {
            bool exists = _db.Get <T>().Any();

            if (!exists || force)
            {
                await _db.DeleteAsync <T>();

                IEnumerable <T2> items = await _session.Query(query);

                var data = items.Select(func).ToArray();
                _db.InsertAsync(data);
                await _db.CommitChanges();
            }
        }