Ejemplo n.º 1
0
        public ActionResult Article(string articleAlias)
        {
            InformationPageDTO informationPageDTO = _informationService.GetArticlePage(articleAlias);

            if (informationPageDTO == null)
            {
                return(NotFound());
            }

            IMapper mapper = new MapperConfiguration(cfg => cfg.CreateMap <InformationPageDTO, InformationPageViewModel>()).CreateMapper();
            InformationPageViewModel model = mapper.Map <InformationPageViewModel>(informationPageDTO);

            if (_siteSettings.TryGetValue("BigBannerId", out string bannerIdString))
            {
                if (int.TryParse(bannerIdString, out int singleBannerId))
                {
                    BannerDTO bannerDTO = _bannerService.GetBanner(singleBannerId);

                    IMapper bannerMapper = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <BannerDTO, BannerViewModel>();
                        cfg.CreateMap <ImageDTO, ImageViewModel>();
                    }).CreateMapper();
                    BannerViewModel banner = bannerMapper.Map <BannerViewModel>(bannerDTO);
                    ViewBag.SingleBanner = banner;
                }
            }

            ViewBag.Title = model.Title;

            return(View(model));
        }