Exemplo n.º 1
0
        public ActionResult Index(string categoryName)
        {
            CategoryModel category;

            try
            {
                category = productsService.GetCategory(categoryName);
            }
            catch (ClientException)
            {
                return(NotFoundResult());
            }

            CategoryViewModel viewModel =
                new CategoryViewModel()
            {
                Breadcrumb      = BreadcrumbHelper.GetCategoryBreadcrumb(Url, category.Title, categoryName),
                MainHeading     = category.Title,
                Sections        = ContentSectionHelper.MapContentSectionsToViewModels(category.ContentSections),
                Products        = ProductHelper.MapProductsToViewModels(category.Products),
                BannerImageUrl  = TourtechUrlHelper.GetImageUrl(category.BannerImageRelativeUrl),
                Title           = category.MetaData.Title,
                MetaDescription = category.MetaData.MetaDescription
            }
            ;

            SetLayout(viewModel);

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public ActionResult Index(string productName)
        {
            CategoryModel category;

            try
            {
                category = productsService.GetCategoryByProduct(productName);
            }
            catch (ClientException)
            {
                return(NotFoundResult());
            }

            ProductModel product = category.Products.Single(a => a.Name == productName);

            ProductViewModel indexViewModel = new ProductViewModel(
                ContentSectionHelper.MapContentSectionsToViewModels(product.ContentSections),
                product.GalleryImages.Select(b => ImageHelper.MapImageToViewModel(b)),
                product.OverviewParagraphs,
                product.Features
                )
            {
                Breadcrumb      = BreadcrumbHelper.GetProductBreadcrumb(Url, category.Title, category.Name, product.Title, product.Name),
                MainHeading     = product.Title,
                BannerImageUrl  = TourtechUrlHelper.GetImageUrl(product.BannerImageRelativeUrl),
                Title           = product.MetaData.Title,
                MetaDescription = product.MetaData.MetaDescription
            };

            SetLayout(indexViewModel);

            return(View(indexViewModel));
        }