예제 #1
0
        // GET: VideoGames
        public async Task <IActionResult> Index(string searchString, string videogamepublisher)

        {
            var VideoGameList = from v in _context.VideoGame
                                select v;

            if (!String.IsNullOrEmpty(searchString))
            {
                VideoGameList = VideoGameList.Where(v => v.Title.Contains(searchString));
            }


            IQueryable <string> publisherQuery = from v in _context.VideoGame
                                                 orderby v.Publisher
                                                 select v.Publisher;

            if (!String.IsNullOrEmpty(videogamepublisher))
            {
                VideoGameList = VideoGameList.Where(v => v.Publisher == videogamepublisher
                                                    );
            }

            var videogamepublisherVM = new VideoGameViewModel();

            videogamepublisherVM.publisher  = new SelectList(await publisherQuery.Distinct().ToListAsync());
            videogamepublisherVM.videoGames = await VideoGameList.ToListAsync();

            return(View(videogamepublisherVM));
        }
        public JsonResult Search(string searchString)
        {
            var vms = new List <VideoGameViewModel>();

            var foundGames = VideoGameService.GetVideoGameByName(searchString);

            foreach (var game in foundGames)
            {
                var vm = new VideoGameViewModel(game);
                vm.PlatformName = PlatformService.Get(game.PlatformId).Name;
                vm.RatingName   = RatingService.Get(game.RatingId).Name;
                vms.Add(vm);
            }

            return(Json(vms, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        // GET: VideoGames
        public ActionResult Index()
        {
            VideoGameViewModel videoGame = new VideoGameViewModel(db.VideoGames.ToList());

            return(View(videoGame));
        }