コード例 #1
0
ファイル: GameController.cs プロジェクト: lorfol/GameStore
        public ActionResult CreateGame(CreateGameViewModel model)
        {
            var game = Mapper.Map <CreateGameViewModel, Game>(model);

            if (model.SelectedPlatforms.Any())
            {
                game.Platforms = _platformManager.Find(x => model.SelectedPlatforms.Any(f => f == x.Id)).ToList();
            }

            if (model.SelectedGenres.Any())
            {
                game.Genres = _genreManager.Find(x => model.SelectedGenres.Any(f => f == x.Id)).ToList();
            }

            if (model.SelectedPublishers.Any())
            {
                game.Publishers = _publisherManager.Find(x => model.SelectedPublishers.Any(f => f == x.Id)).ToList();
            }

            game.AddingDate = DateTime.UtcNow;
            var request = _gameManager.CreateNewGame(game);

            if (request != HttpStatusCode.Created)
            {
                throw new ValidationException("Invalid form data.");
            }

            return(RedirectToAction("GetAllGames"));
        }
コード例 #2
0
        public ActionResult PublisherDetails(string companyName)
        {
            var publisher = _publisherManager.Find(x => x.CompanyName == companyName).SingleOrDefault();

            if (publisher != null)
            {
                return(View("PublisherDetails", Mapper.Map <Publisher, PublisherViewModel>(publisher)));
            }

            ViewBag.ErrorMessage = $"Publisher \"{companyName}\" was deleted.";

            return(View("Error"));
        }