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);
        }
 public async Task <MatchInfo> GetMatch(MatchInfo.MatchInfoId matchId)
 {
     using (var session = store.OpenAsyncSession())
     {
         return(await session
                .Query <MatchInfo.MatchInfoId, MatchByIdAndTime>()
                .Customize(q => q.WaitForNonStaleResults())
                .Where(m => m.ServerId == matchId.ServerId && m.EndTime == matchId.EndTime)
                .OfType <MatchInfo>()
                .FirstOrDefaultAsync());
     }
 }
        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();
            }
        }
 public void AddMatch(MatchInfo.MatchInfoId matchId, MatchInfo match)
 {
     A.CallTo(() => storage.GetMatch(matchId)).Returns(match);
 }
        public async Task <MatchInfo> GetMatch(MatchInfo.MatchInfoId matchId)
        {
            logger.ConditionalTrace("Retrieve information about match {0}", new { MatchId = matchId });

            return(await statisticStorage.GetMatch(matchId));
        }