Beispiel #1
0
        public ActionResult Index(int? platformId, int? genreId)
        {
            var games = facade.GetGameGateway().GetAll().ToList();
            var genres = facade.GetGenreGateway().GetAll().ToList();
            var platforms = facade.GetPlatformGateway().GetAll().ToList();

            if (genreId != null)
            {
                var newGames = from g in games
                           where g.Genres.Any(genre => genre.Id == genreId)
                           select g;
                GamePlatformGenre gpgGenre = new GamePlatformGenre(newGames.ToList(), genres, platforms);
                return View(gpgGenre);
            }
            if (platformId != null)
            {
                var platformGames = facade.GetPlatformGameGateway().GetAll().ToList().Where(p =>p.PlatformId ==platformId);

                var newGames = new List<GameDTO>();
                foreach(var platformGame in platformGames)
                {
                    newGames.Add(platformGame.Game);
                }
                GamePlatformGenre gpgPlatform = new GamePlatformGenre(newGames, genres, platforms);
                return View(gpgPlatform);

            }
            GamePlatformGenre gpg = new GamePlatformGenre(games, genres, platforms);
            return View(gpg);
        }
Beispiel #2
0
        public ActionResult Index(string search)
        {
            var genres = facade.GetGenreGateway().GetAll().ToList();
            var platforms = facade.GetPlatformGateway().GetAll().ToList();
            var games = facade.GetGameGateway().GetAll().ToList();
            var newGames = games.Where(g => g.Title.ToLower().Contains(search.ToLower()));

            GamePlatformGenre gpg = new GamePlatformGenre(newGames.ToList(), genres, platforms);
            return View(gpg);
        }