Esempio n. 1
0
        public ActionResult Update(string gameKey)
        {
            Game game = _gameService.GetByKey(gameKey, CurrentLangCode);

            if (game == null)
            {
                throw new Exception("game with that key not found");
            }

            UpdateGameModel model = new UpdateGameModel();

            model.Game           = game;
            model.SelectedGenres = game.Genres != null?game.Genres.Select(a => a.Name).ToList() : null;

            model.SelectedPlatforms = game.Platforms != null?game.Platforms.Select(a => a.Name).ToList() : null;

            model.SelectedPublisher   = game.Publisher != null ? game.Publisher.CompanyName : null;
            model.AvailableGenres     = _genreService.GetAllItems();
            model.AvailablePlatforms  = _platformService.GetAllItems();
            model.AvailablePublishers = _publisherService.GetAllItems();
            model.languages           = _languageService.GetAllLanguages();

            GameLang gameLang = _languageService.GetGameLocalizations(game.Id).FirstOrDefault();

            if (gameLang != null)
            {
                model.LangCode = gameLang.Language.Code;
                model.additionalDescription = gameLang.Description;
            }
            return(View("Update", model));
        }
Esempio n. 2
0
        private void InitializeFilters(IFilterChain <IQueryable <Game> > gameFilter, IFilterChain <IQueryable <Product> > productFilter, FilterArgs model)
        {
            gameFilter.Register(new GenreFilter(model.SelectedGenres ?? _genreService.GetAllItems().Select(x => x.Id)));
            gameFilter.Register(new PlatformFilter(model.SelectedPlatforms ?? _platformService.GetAllItems().Select(x => x.Id)));
            gameFilter.Register(new PublisherFilter(model.SelectedPublishers ?? _publisherService.GetAllItems().Select(x => x.Id)));
            gameFilter.Register(new PriceFilter((double)model.MinPrice, (double)model.MaxPrice));
            gameFilter.Register(new GameNameFilter(model.GameName));
            gameFilter.Register(new DateFilter((model.SelectedDate ?? new DatesFilter()).ToString()));


            productFilter.Register(new CategoryFilter(model.SelectedGenres));
            productFilter.Register(new SupplierFilter(model.SelectedPublishers));
            productFilter.Register(new ProductPriceRangeFilter(model.MinPrice, model.MaxPrice));
            productFilter.Register(new ProductNameFilter(model.GameName));
        }