public IActionResult Index() { PlatformIndexViewModel viewModel = new PlatformIndexViewModel { Platforms = platformService.GetAll(), PlatformTypes = platformTypeService.GetAll() }; return(View(viewModel)); }
public ActionResult GetAll() { var platformTypesDto = _platformTypeService.GetAll(); var platformTypesViewModel = _mapper.Map <IEnumerable <DetailsPlatformTypeViewModel> >(platformTypesDto); return(View(platformTypesViewModel)); }
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)); }
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)); }
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); }
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); }