public IActionResult Index() { var banner = bannerService.GetBanner(); if (banner == null) { return(View()); } ViewData["Banner"] = banner; return(View()); }
public IActionResult BannerById(string id) { var banner = _service.GetBanner(id); if (banner == null) { return(NotFound()); } return(Ok(banner)); }
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)); }
public ActionResult Cart() { IMapper mapper = new MapperConfiguration(cfg => { cfg.CreateMap <Cart, CartViewModel>(); cfg.CreateMap <CartLineDTO, CartLine>(); cfg.CreateMap <ProductPageDTO, ProductPageViewModel>(); cfg.CreateMap <ImageDTO, ImageViewModel>(); }).CreateMapper(); CartViewModel model = mapper.Map <CartViewModel>(_cart); 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; } } return(View(model)); }
public ActionResult Index() { HomePageDTO homePageDTO = _commonService.GetHomePage(); IMapper homePageMapper = new MapperConfiguration(cfg => { cfg.CreateMap <HomePageDTO, HomePageViewModel>(); cfg.CreateMap <ProductPageDTO, ProductPageViewModel>(); cfg.CreateMap <ImageDTO, ImageViewModel>(); }).CreateMapper(); HomePageViewModel model = homePageMapper.Map <HomePageViewModel>(homePageDTO) ?? new HomePageViewModel { Title = "Главная страница" }; if (_siteSettings.TryGetValue("HomeSliderId", out string bannerGroupIdString)) { if (int.TryParse(bannerGroupIdString, out int bannerGroupId)) { BannerGroupDTO bannerGroupDTO = _bannerService.GetBannerGroup(bannerGroupId); IMapper BannerGroupMapper = new MapperConfiguration(cfg => { cfg.CreateMap <BannerGroupDTO, BannerGroupViewModel>(); cfg.CreateMap <BannerDTO, BannerViewModel>(); cfg.CreateMap <ImageDTO, ImageViewModel>(); }).CreateMapper(); BannerGroupViewModel bannerGroup = BannerGroupMapper.Map <BannerGroupViewModel>(bannerGroupDTO); ViewBag.HomeBannerGroup = bannerGroup; } } if (_siteSettings.TryGetValue("SmallBannerId", 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)); }
public ActionResult DeleteBanner(int?id) { UserPermissionAction("admin", RoleAction.create.ToString()); CheckPermission(); var Banner = _BannerService.GetBanner(Convert.ToInt32(id)); if (Banner != null) { _BannerService.DeleteBanner(Banner); } id = Convert.ToInt32(Session["CustomerId"]); return(RedirectToAction("BannerDetail/" + id + "")); }
public ActionResult Product(string productAlias) { ProductPageDTO productPageDTO = _productService.GetProductPage(productAlias); if (productPageDTO == null) { return(NotFound()); } IMapper mapper = new MapperConfiguration(cfg => { cfg.CreateMap <ProductPageDTO, ProductPageViewModel>(); cfg.CreateMap <ImageDTO, ImageViewModel>(); }).CreateMapper(); ProductPageViewModel model = mapper.Map <ProductPageViewModel>(productPageDTO); 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)); }
public ActionResult Checkout() { if (!_cart.CartLines.Any()) { return(RedirectToAction("Cart", "Cart")); } 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; } } IMapper mapper = new MapperConfiguration(cfg => { cfg.CreateMap <CartLineDTO, CartLine>(); cfg.CreateMap <ProductPageDTO, ProductPageViewModel>(); cfg.CreateMap <ImageDTO, ImageViewModel>(); }).CreateMapper(); IList <CartLine> cartLines = mapper.Map <IList <CartLine> >(_cart.CartLines); CheckoutViewModel model = new CheckoutViewModel { CartLines = cartLines, TotalValue = _cart.TotalValue }; return(View(model)); }
public ActionResult <Banner> GetBanner(int id) { return(bannerService.GetBanner(id)); }