Ejemplo n.º 1
0
        public IActionResult Details(int id)
        {
            var game = gameRepository.Get(id);

            if (game == null)
            {
                throw new InvalidOperationException("Entity does not exist.");
            }

            UpdateStatistics(game);

            var model = new BoardGameDetailsViewModel()
            {
                GameId           = game.Id,
                Name             = game.Name,
                MinPlayerAge     = game.MinPlayerAge,
                MaxPlayersNumber = game.MaxPlayersNumber,
                MinPlayersNumber = game.MinPlayersNumber,
                Statistics       = gameStatisticsService.GetStatisticsForGame(game.Id)
                                   .Select(s => new GameStatisticViewModel()
                {
                    Source = s.Source.GetAttribute <DisplayAttribute>().Name, ViewedDate = s.ViewedDate
                })
                                   .ToList()
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public BoardGame Get(int id)
        {
            if (id <= Decimal.Zero)
            {
                throw new BoardGameServiceException("Invalid identifier.");
            }

            var entity = _boardGameRepository.Get(id);

            if (entity is null)
            {
                throw new BoardGameServiceException("Game not available.");
            }

            return(entity);
        }
Ejemplo n.º 3
0
        private GameResult MapGameResultDtoToGameResultWithReferences(GameResultDto gameResultDto, Gamer gamer)
        {
            GameTable gameTable = null;

            if (gameResultDto.GameTableId.HasValue)
            {
                gameTable = _gameTableRepository.Get(gameResultDto.GameTableId.Value);
            }

            var boardGame = _boardGameRepository.Get(gameResultDto.BoardGameId);

            var gameResult = Mapper.Map <GameResultDto, GameResult>(gameResultDto);

            Mapper.Map(gamer, gameResult);
            Mapper.Map(gameTable, gameResult);
            Mapper.Map(boardGame, gameResult);
            return(gameResult);
        }
Ejemplo n.º 4
0
        public ActionResult <BoardGameDetailsModel> Details(int id)
        {
            var game = boardGameRepository.Get(id);

            if (game == null)
            {
                return(NotFound());
            }

            UpdateStatistics(game);

            return(new BoardGameDetailsModel()
            {
                Id = game.Id,
                MinPlayerAge = game.MinPlayerAge,
                MaxPlayersNumber = game.MaxPlayersNumber,
                MinPlayersNumber = game.MinPlayersNumber,
                Name = game.Name
            });
        }
Ejemplo n.º 5
0
 public BoardGame Get(int id)
 {
     return(_boardGameRepository.Get(id));
 }
 public BoardGame Get(Guid id)
 {
     return(_repository.Get(id));
 }