public async Task UpdateMatch(MatchInfo.MatchInfoId matchId, MatchInfo match)
        {
            logger.ConditionalTrace("Update information about match {0}",
                                    new { MatchId = matchId, MatchInfo = match });

            var server = await statisticStorage.GetServer(new ServerInfo.ServerInfoId {
                Id = matchId.ServerId
            });

            if (server == null)
            {
                return;
            }
            match.HostServer = server;
            match            = match.InitPlayers(match.EndTime);

            var oldMatchInfo = await statisticStorage.GetMatch(match.GetIndex());

            if (oldMatchInfo != null)
            {
                DeleteMatch(oldMatchInfo.InitPlayers(oldMatchInfo.EndTime));
            }
            await statisticStorage.UpdateMatch(matchId, match);

            InsertMatch(match);
        }
Esempio n. 2
0
        public async Task TotalMatchesPlayedTest()
        {
            await StatisticStorage.UpdateServer(Server1.GetIndex(), Server1);

            MatchInfo match1 = GenerateMatch(Server1, Day1), match2 = GenerateMatch(Server1, Day3);
            await StatisticStorage.UpdateMatch(match1.GetIndex(), match1);

            await StatisticStorage.UpdateMatch(match2.GetIndex(), match2);

            await WaitForTasks();

            ServerStatisticStorage.GetStatistics(Server1.Id).TotalMatchesPlayed.Should().Be(2);
        }
Esempio n. 3
0
        public async Task UpdateMatch(MatchInfo.MatchInfoId matchId, MatchInfo match)
        {
            using (var session = store.OpenAsyncSession())
            {
                var existed = await GetMatch(match.GetIndex());

                if (existed != null)
                {
                    match.Id = existed.Id;
                }
                await session.StoreAsync(match);

                await session.SaveChangesAsync();
            }
        }