Ejemplo n.º 1
0
        public async Task<IList<GameResultDTO>> TopLeaderBoardResultsAsync()
        {
            var results = new List<GameResultDTO>();

            if (_leaderBoardStorageContainer == null)
            {
                _leaderBoardStorageContainer = await _leaderBoardStorageHelper.LoadASync(DimesoftMemoryFileName);
            }

            // do this check here because it is possible the Load will return a null if nothing is found
            if (_leaderBoardStorageContainer != null)
            {
                results = _leaderBoardStorageContainer.Results                    
                    .OrderBy(x => x.Attempts)
                    .Take(5).ToList();
            }

            return results;
        }
Ejemplo n.º 2
0
        public async Task<IList<GameResultDTO>> LeaderBoardResultsAsync(string category, string level)
        {
            var results = new List<GameResultDTO>();

            if (_leaderBoardStorageContainer == null)
            {
                _leaderBoardStorageContainer = await _leaderBoardStorageHelper.LoadASync(DimesoftMemoryFileName);
            }

            // do this check here because it is possible the Load will return a null if nothing is found
            if (_leaderBoardStorageContainer != null)
            {
                results = _leaderBoardStorageContainer.Results
                    .Where(x => x.GameCategory == category && x.GameLevel == level)
                    .OrderByDescending(x => x.GameTime)
                    .ToList();
            }
                                               
            return results;
        }
Ejemplo n.º 3
0
        public async Task AddGameResultAsync(GameResultDTO result)
        {
            if (_leaderBoardStorageContainer == null)
            {
                _leaderBoardStorageContainer = new LeaderBoardStorageContainer();
            }

            _leaderBoardStorageContainer.Results.Add(result);

            _leaderBoardStorageHelper.SaveASync(_leaderBoardStorageContainer, DimesoftMemoryFileName);
        }