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)); }
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); }
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); }
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 }); }
public BoardGame Get(int id) { return(_boardGameRepository.Get(id)); }
public BoardGame Get(Guid id) { return(_repository.Get(id)); }