예제 #1
0
        // GET: Games/Edit/5
        public async Task <IActionResult> Edit(int id)
        {
            try {
                var game = await _gameService.Find(id);

                var publisherRequest = new PublisherSearchRequest {
                    PerPage = 500
                };

                var developerRequest = new DeveloperSearchRequest {
                    PerPage = 500
                };

                var publishers = await _publisherService.All(publisherRequest);

                var developers = await _developerService.All(developerRequest);

                ViewBag.Publishers = (List <SharedModels.DTO.Publisher.Publisher>)publishers.Data;
                ViewBag.Developers = (List <SharedModels.DTO.Developer.Developer>)developers.Data;
                ViewBag.Game       = (SharedModels.DTO.Game.Game)game;
                ViewBag.ageLabels  = new[] { 3, 7, 12, 16, 18 };

                ViewBag.gameModes = Enum.GetValues(typeof(GameModes));

                return(View());
            } catch (EntityNotFoundException e) {
                TempData["error"] = e.Message;
                return(RedirectToAction(nameof(Index)));
            } catch (Exception e) {
                TempData["error"] = e.Message;
                return(RedirectToAction(nameof(Index)));
            }
        }
        // GET: Developers
        public async Task <ActionResult> Index([FromQuery] DeveloperSearchRequest request)
        {
            int total = await _developerService.Count();

            var developers = await _developerService.All(request);

            var data = developers.Data;

            ViewData["total"]      = total;
            ViewData["pagesCount"] = developers.PagesCount;
            return(View(data));
        }
예제 #3
0
        // GET: Games/Create
        public async Task <ActionResult> Create()
        {
            var publisherRequest = new PublisherSearchRequest {
                PerPage = 500
            };

            var developerRequest = new DeveloperSearchRequest {
                PerPage = 500
            };

            var publishers = await _publisherService.All(publisherRequest);

            var developers = await _developerService.All(developerRequest);

            ViewBag.Publishers = (List <SharedModels.DTO.Publisher.Publisher>)publishers.Data;
            ViewBag.Developers = (List <SharedModels.DTO.Developer.Developer>)developers.Data;

            return(View());
        }
        public async Task <ActionResult <PagedResponse <IEnumerable <Developer> > > > Get([FromQuery] DeveloperSearchRequest request)
        {
            var developers = await _developerService.All(request);

            return(Ok(developers));
        }