Пример #1
0
        public ActionResult EditGame(int id)
        {
            var gameEntity = _gameLogic.GetById(id);

            if (gameEntity == null)
            {
                return(HttpNotFound());
            }

            var gameForEdit = Mapper.Map <GameEntity, EditGameVm>(gameEntity);

            gameForEdit.GenreIds = _genreLogic.GetByGameId(gameForEdit.Id).Select(g => g.Id);

            return(View(gameForEdit));
        }
Пример #2
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var gameEntity = _gameLogic.GetById(id.Value);

            if (gameEntity == null)
            {
                return(HttpNotFound());
            }

            var game   = Mapper.Map <GameEntity, DisplayGameVm>(gameEntity);
            var genres = _genreLogic.GetByGameId(game.Id);

            game.Genres = genres != null?
                          string.Join(", ", genres.Select(g => g.Name))
                              : null;

            return(View(game));
        }