public async Task <Result <CoinFlipMatchHistory> > GetHistory(int start, int count)
        {
            var filter = GetFindFilter().Where(match => match.Status == MatchStatusHelper.GetIntFromMatchStatus(MatchStatus.Closed));

            var res = await MongoDbHelper.Query(GetCollection().Collection, filter, start, count, match => match.TimerStarted);

            var result = new Result <CoinFlipMatchHistory>
            {
                CurrentIndex = start,
                Total        = res.Total,
                Data         = res.Data.Select(i => new CoinFlipMatchHistory(i)).ToList()
            };

            return(result);
        }
        public async Task <Result <CoinFlipMatchHistory> > GetPersonalHistory(int start, int count, string steamId)
        {
            var betFilter = new BsonDocumentFilterDefinition <MongoDbModels.JackpotMatch>(new BsonDocument("Bets.User.SteamId", steamId));

            var filter = GetFindFilter().And
                         (
                betFilter,
                GetFindFilter().Where(match => match.Status == MatchStatusHelper.GetIntFromMatchStatus(MatchStatus.Closed))
                         );

            var res = await MongoDbHelper.Query(GetCollection().Collection, filter, start, count, match => match.TimerStarted);

            var result = new Result <CoinFlipMatchHistory>
            {
                CurrentIndex = start,
                Total        = res.Total,
                Data         = res.Data.Select(i => new CoinFlipMatchHistory(i)).ToList()
            };

            return(result);
        }
Exemplo n.º 3
0
        protected async Task <DatabaseModel.Match> CreateNewMatchAsync(int roundId, DatabaseModel.GameMode currentGameMode)
        {
            var percentage = _randomService.GeneratePercentage();
            var salt       = _randomService.GenerateSalt();
            var hash       = _hashService.CreateBase64Sha512Hash(percentage, salt);
            var status     = MatchStatusHelper.GetIntFromMatchStatus(MatchStatus.Open);

            var match = new DatabaseModel.Match
                        (
                roundId,
                salt,
                hash,
                percentage,
                status,
                null,
                null,
                currentGameMode.CurrentSettingId,
                currentGameMode.Id,
                DateTime.Now
                        );

            return(await _matchRepoService.InsertAsync(match));
        }
Exemplo n.º 4
0
 public void MatchIsClosedReturnsIntSucces()
 {
     Assert.Equal(0, MatchStatusHelper.GetIntFromMatchStatus(MatchStatus.Closed));
 }
Exemplo n.º 5
0
 public void MatchIsOpenReturnsIntSucces()
 {
     Assert.Equal(1, MatchStatusHelper.GetIntFromMatchStatus(MatchStatus.Open));
 }
Exemplo n.º 6
0
 public async Task CloseMatch(int roundId)
 {
     var query = _matchQueries.ChangeMatchStatus(roundId, MatchStatusHelper.GetIntFromMatchStatus(MatchStatus.Closed));
     await _databaseConnection.ExecuteNonQueryAsync(query);
 }