コード例 #1
0
        public IActionResult Index()
        {
            PlatformIndexViewModel viewModel = new PlatformIndexViewModel
            {
                Platforms     = platformService.GetAll(),
                PlatformTypes = platformTypeService.GetAll()
            };

            return(View(viewModel));
        }
コード例 #2
0
        public ActionResult GetAll()
        {
            var platformTypesDto       = _platformTypeService.GetAll();
            var platformTypesViewModel = _mapper.Map <IEnumerable <DetailsPlatformTypeViewModel> >(platformTypesDto);

            return(View(platformTypesViewModel));
        }
コード例 #3
0
        public ActionResult GetGameDetails(string key)
        {
            GameModel gameModel     = _gameService.GetGameModelByKey(key);
            var       gameViewModel = Mapper.Map <GameViewModel>(gameModel);

            gameViewModel.PlatformTypes = Mapper.Map <IEnumerable <PlatformTypeViewModel> >(_platformTypeService.GetAll());
            gameViewModel.Genres        = Mapper.Map <IEnumerable <GenreViewModel> >(_genreService.GetAll());
            if (gameModel.PublisherId != null)
            {
                gameViewModel.Publisher =
                    Mapper.Map <PublisherViewModel>(_publisherService.GetModelById((int)gameModel.PublisherId));
            }

            return(View(gameViewModel));
        }
コード例 #4
0
        public HttpResponseMessage Get(int id)
        {
            GameModel gameModel = _gameService.GetGameModelById(id);

            if (gameModel == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }

            var gameViewModel = Mapper.Map <GameViewModel>(gameModel);

            gameViewModel.PlatformTypes = Mapper.Map <IEnumerable <PlatformTypeViewModel> >(_platformTypeService.GetAll());
            gameViewModel.Genres        = Mapper.Map <IEnumerable <GenreViewModel> >(_genreService.GetAll());
            if (gameModel.PublisherId != null)
            {
                gameViewModel.Publisher =
                    Mapper.Map <PublisherViewModel>(_publisherService.GetModelById((int)gameModel.PublisherId));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, gameViewModel));
        }
コード例 #5
0
ファイル: GameController.cs プロジェクト: antinka/Diploma
        private GameViewModel CreateCheckBoxForGameViewModel(GameViewModel gameViewModel)
        {
            var genrelist    = _mapper.Map <IEnumerable <DelailsGenreViewModel> >(_genreService.GetAll());
            var platformlist = _mapper.Map <IEnumerable <DetailsPlatformTypeViewModel> >(_platformTypeService.GetAll());
            var publishers   = _mapper.Map <IEnumerable <DetailsPublisherViewModel> >(_publisherService.GetAll());

            gameViewModel.PublisherList = new SelectList(publishers, "Id", "Name");

            var listGenreBoxes = new List <CheckBox>();

            genrelist.Select(genre =>
            {
                listGenreBoxes.Add(new CheckBox()
                {
                    Text = genre.Name
                }); return(genre);
            }).ToList();
            gameViewModel.ListGenres = listGenreBoxes;

            var listPlatformBoxes = new List <CheckBox>();

            platformlist.Select(platform =>
            {
                listPlatformBoxes.Add(new CheckBox()
                {
                    Text = platform.Name
                }); return(platform);
            }).ToList();
            gameViewModel.ListPlatformTypes = listPlatformBoxes;

            return(gameViewModel);
        }
コード例 #6
0
        public FilterViewModel Build()
        {
            var model         = new FilterViewModel();
            var genresDto     = _genreService.GetAll();
            var genrelist     = _mapper.Map <IEnumerable <DelailsGenreViewModel> >(genresDto);
            var platformlist  = _mapper.Map <IEnumerable <DetailsPlatformTypeViewModel> >(_platformTypeService.GetAll());
            var publisherlist = _mapper.Map <IEnumerable <DetailsPublisherViewModel> >(_publisherService.GetAll());

            var listGenreBoxs = new List <CheckBox>();

            genrelist.ToList().ForEach(genre => listGenreBoxs.Add(new CheckBox()
            {
                Text = genre.Name
            }));
            model.ListGenres = listGenreBoxs;

            var listPlatformBoxs = new List <CheckBox>();

            platformlist.ToList().ForEach(platform => listPlatformBoxs.Add(new CheckBox()
            {
                Text = platform.Name
            }));
            model.ListPlatformTypes = listPlatformBoxs;

            var listPublisherBoxs = new List <CheckBox>();

            publisherlist.ToList().ForEach(publisher => listPublisherBoxs.Add(new CheckBox()
            {
                Text = publisher.Name
            }));
            model.ListPublishers = listPublisherBoxs;

            return(model);
        }