Exemplo n.º 1
0
        public static void AssertProductsLoaded(this HttpContextBase httpContext, ICatalogApi catalogApi, ContentItem currentItem, long?pageProductId = null)
        {
            if (catalogApi == null)
            {
                return;
            }

            var page = currentItem as PageModelBase;

            if (page == null)
            {
                return;
            }

            var pids = page.ProductIds.ToList();

            if (pageProductId != null && !pids.Contains(pageProductId.Value))
            {
                pids.Add(pageProductId.Value);
            }

            var products       = catalogApi.GetProductsAsync(pids).Result;
            var dictOfProducts = products.ToDictionary(p => p.Id);

            httpContext.Items["Products"] = dictOfProducts;
            var bogusProductIds = pids.Where(p => !dictOfProducts.ContainsKey(p)).ToList();

            httpContext.Items["BogusProductIds"] = bogusProductIds;
        }
 public CheckOutModel(ICatalogApi catalogApi, IBasketApi basketApi, IUserApi userApi, IOrderApi orderApi)
 {
     _catalogApi = catalogApi ?? throw new ArgumentNullException(nameof(catalogApi));
     _basketApi  = basketApi ?? throw new ArgumentNullException(nameof(basketApi));
     _userApi    = userApi ?? throw new ArgumentNullException(nameof(_userApi));
     _orderApi   = orderApi ?? throw new ArgumentNullException(nameof(_orderApi));
 }
Exemplo n.º 3
0
 public ProductController(ICatalogApi catApi, IProductViewModelBuilder prodViewModelBuilder, IRequestLogger logger, ILinkGenerator linkGenerator, IPageInfo pageInfo)
     : base(logger, linkGenerator, catApi)
 {
     _pageInfo             = pageInfo;
     _prodViewModelBuilder = prodViewModelBuilder;
     _catApi = catApi;
 }
        public CategoryListViewModel GetCategoryListViewModel(CategoryListPart part, ILinkGenerator linkGenerator, ICatalogApi catalogApi)
        {
            var model = new CategoryListViewModel { Title = part.Title };

            foreach (var category in part.Categories)
            {
                var itemModel = new CategoryListItemViewModel
                {
                    Url = category.TargetUrl,
                    Title = category.Title,
                    Text = category.Text
                };
                long cid;
                if (long.TryParse(category.Category, out cid))
                {
                    itemModel.Category = catalogApi.GetCategoryAsync(catalogApi.GetCategoryUri(cid)).Result;
                    if (string.IsNullOrEmpty(itemModel.Url))
                        itemModel.Url = linkGenerator.GenerateCategoryLink(cid);
                    if (string.IsNullOrEmpty(itemModel.Title))
                        itemModel.Title = itemModel.Category.DisplayName;
                    if (string.IsNullOrEmpty(itemModel.Text))
                        itemModel.Text = itemModel.Category.ShortDescription;
                }
                model.Categories.Add(itemModel);
            }

            return model;
        }
 public SitemapController(ICatalogApi catalogApi, ICategoryViewModelBuilder catViewModelBuilder, ILinkGenerator linkGenerator)
 {
     _catalogApi          = catalogApi;
     _linkGenerator       = linkGenerator;
     _catViewModelBuilder = catViewModelBuilder;
     _siteConfig          = ConfigLoader.Get <SiteConfig>();
 }
        public ProductListViewModel GetProductListViewModel(ProductListPart part, ILinkGenerator linkGenerator, ICatalogApi catalogApi)
        {
            var model = new ProductListViewModel {Title = part.Title};

            foreach (var product in part.Products)
            {
                var itemModel = new ProductListItemViewModel
                {
                    Url = product.TargetUrl,
                    Title = product.Title,
                    Text = product.Text
                };
                long pid;
                if (long.TryParse(product.Product, out pid))
                {
                    itemModel.Product = catalogApi.GetProductAsync(catalogApi.GetProductUri(pid)).Result;
                    if (string.IsNullOrEmpty(itemModel.Url))
                        itemModel.Url = linkGenerator.GenerateProductLink(pid);
                    if (string.IsNullOrEmpty(itemModel.Title))
                        itemModel.Title = itemModel.Product.DisplayName;
                    if (string.IsNullOrEmpty(itemModel.Text))
                        itemModel.Text = itemModel.Product.ShortDescription;
                }
                model.Products.Add(itemModel);
            }

            return model;
        }
Exemplo n.º 7
0
 public Railway(ICatalogApi catalogApi,
                IProductApi productApi,
                IProductConverter productConverter)
 {
     this.catalogApi       = catalogApi;
     this.productApi       = productApi;
     this.productConverter = productConverter;
 }
 public CatalogController(IRequestLogger logger, ICategoryViewModelBuilder catViewModelBuilder,
                          ILinkGenerator linkGenerator,
                          IPageInfo pageInfo, ICatalogApi catalogApi)
     : base(logger, linkGenerator, catalogApi)
 {
     _pageInfo            = pageInfo;
     _linkGenerator       = linkGenerator;
     _catViewModelBuilder = catViewModelBuilder;
 }
        public ContentControllerBase(ICatalogApi catalogApi)
        {
            _catalogApi      = catalogApi;
            TempDataProvider = null;

#if SAVE_VIEW_MODEL
            _saveVmDir = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/SavedViewModels");
            if (!Directory.Exists(_saveVmDir))
            {
                Directory.CreateDirectory(_saveVmDir);
            }
#endif
        }
        public ContentControllerBase(IRequestLogger logger, ILinkGenerator linkGenerator, ICatalogApi catalogApi)
        {
            _catalogApi = catalogApi;

            Logger        = logger;
            LinkGenerator = linkGenerator;

#if SAVE_VIEW_MODEL
            _saveVmDir = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/SavedViewModels");
            if (!Directory.Exists(_saveVmDir))
            {
                Directory.CreateDirectory(_saveVmDir);
            }
#endif
        }
 public async Task<OfferListViewModel> GetProductOfferListAsync(ProductOfferListPart productOfferListPart, IProductPart page, ICatalogApi catalogApi)
 {
     // The driving product is taken off of either the product on the page (if the page is a product page) or off of the "Product" picker on the part.
     // The Product picker will override the page's product.
     long pid;
     if (!long.TryParse(productOfferListPart.Product, out pid) || pid == 0)
     {
         if (page != null && page.Product.Contains(","))
         {
             var parts = page.Product.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
             if (parts.Length > 0)
                 long.TryParse(parts[0], out pid);
         }
     }
     if (pid == 0)
         return await GetOfferListAsync(productOfferListPart).ConfigureAwait(false);
     if (String.IsNullOrEmpty(productOfferListPart.PopName))
         return new OfferListViewModel();
     var offers = await _offersApi.GetOffersAsync(productOfferListPart.PopName, catalogApi.GetProductUri(pid)).ConfigureAwait(false);
     return OffersToOfferListViewModel(productOfferListPart, offers);
 }
 public ProductModel(ICatalogApi catalogApi, IBasketApi basketApi)
 {
     _catalogApi = catalogApi;
     _basketApi  = basketApi;
 }
Exemplo n.º 13
0
 public ListOfLinksAdapter(ILinkGenerator linkGenerator, ICatalogApi catalogApi, IRequestLogger logger)
     : base(logger, catalogApi)
 {
     _linkGenerator = linkGenerator;
 }
 public ProductDetailModel(ICatalogApi catalogApi, IBasketApi basketApi)
 {
     this.catalogApi = catalogApi;
     this.basketApi  = basketApi;
 }
Exemplo n.º 15
0
 public ContentPageController(IRequestLogger logger, ILinkGenerator linkGenerator, IPageInfo pageInfo, ICatalogApi catalogApi)
     : base(logger, linkGenerator, catalogApi)
 {
     _pageInfo = pageInfo;
 }
 public OfferListController(IRequestLogger logger, ILinkGenerator linkGenerator, ICatalogApi catalogApi, IOfferListViewModelBuilder offerListViewModelBuilder)
     : base(logger, linkGenerator, catalogApi)
 {
     _offerListViewModelBuilder = offerListViewModelBuilder;
 }
 public ProductListController(IProductListViewModelBuilder modelBuilder, IRequestLogger logger, ILinkGenerator linkGenerator, ICatalogApi catalogApi)
     : base(logger, linkGenerator, catalogApi)
 {
     _modelBuilder = modelBuilder;
 }
Exemplo n.º 18
0
 public ProductModel(ICatalogApi catalogApi, IBasketApi basketApi)
 {
     _catalogApi = catalogApi ?? throw new ArgumentNullException(nameof(catalogApi));
     _basketApi  = basketApi ?? throw new ArgumentNullException(nameof(basketApi));
 }
Exemplo n.º 19
0
        public async Task <OfferListViewModel> GetProductOfferListAsync(ProductOfferListPart productOfferListPart, IProductPart page, ICatalogApi catalogApi)
        {
            // The driving product is taken off of either the product on the page (if the page is a product page) or off of the "Product" picker on the part.
            // The Product picker will override the page's product.
            long pid;

            if (!long.TryParse(productOfferListPart.Product, out pid) || pid == 0)
            {
                if (page != null && page.Product.Contains(","))
                {
                    var parts = page.Product.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length > 0)
                    {
                        long.TryParse(parts[0], out pid);
                    }
                }
            }
            if (pid == 0)
            {
                return(await GetOfferListAsync(productOfferListPart).ConfigureAwait(false));
            }
            if (String.IsNullOrEmpty(productOfferListPart.PopName))
            {
                return(new OfferListViewModel());
            }
            var offers = await _offersApi.GetOffersAsync(productOfferListPart.PopName, catalogApi.GetProductUri(pid)).ConfigureAwait(false);

            return(OffersToOfferListViewModel(productOfferListPart, offers));
        }
Exemplo n.º 20
0
 public SharedPagesController(ICatalogApi catApi)
 {
     _catApi = catApi;
 }
 public CategoryViewModelBuilder(ICatalogApi catalogApi)
 {
     _catalogApi = catalogApi;
 }
Exemplo n.º 22
0
 public CheckOutModel(ICatalogApi catalogApi, IBasketApi basketApi)
 {
     this.catalogApi = catalogApi;
     this.basketApi  = basketApi;
 }
Exemplo n.º 23
0
 public IndexModel(ICatalogApi catalogApi, IBasketApi basketApi)
 {
     this.catalogApi = catalogApi;
     this.basketApi  = basketApi;
 }
 public ShoppingCartInterstitialController(IPageInfo pageInfo, IProductViewModelBuilder prodViewModelBuilder,
                                           ICatalogApi catalogApi) : base(catalogApi)
 {
     _pageInfo             = pageInfo;
     _prodViewModelBuilder = prodViewModelBuilder;
 }
Exemplo n.º 25
0
 public SearchController(ICatalogApi catalogApi)
 {
     _catalogApi = catalogApi;
 }
Exemplo n.º 26
0
 public ProductDetailModel(IBasketApi basketApi, ICatalogApi catalogApi)
 {
     _basketApi  = basketApi;
     _catalogApi = catalogApi;
 }
 public ProductPickerController(ICatalogApi catalogApi)
 {
     _catalogApi = catalogApi;
 }
 public ProductViewModelBuilder(ICatalogApi catalogApi, IRequestLogger logger)
 {
     _catalogApi = catalogApi;
     _logger     = logger;
 }
Exemplo n.º 29
0
 public IndexModel(IBasketApi basketApi, ICatalogApi catalogApi)
 {
     _basketApi  = basketApi ?? throw new ArgumentNullException(nameof(basketApi));
     _catalogApi = catalogApi ?? throw new ArgumentNullException(nameof(catalogApi));
 }
Exemplo n.º 30
0
 public CheckOutModel(ICatalogApi catalogApi, IBasketApi basketApi)
 {
     _catalogApi = catalogApi;
     _basketApi  = basketApi;
 }
Exemplo n.º 31
0
 public LanguageIntersectionController(IRequestLogger logger, ILinkGenerator linkGenerator, ICatalogApi catalogApi)
     : base(logger, linkGenerator, catalogApi)
 {
 }
 public RecursiveZonePartsAdapterBase(IRequestLogger logger, ICatalogApi catalogApi)
 {
     _logger = logger;
     _catalogApi = catalogApi;
 }
Exemplo n.º 33
0
 public IndexModel(ICatalogApi catalogApi, IBasketApi basketApi)
 {
     _catalogApi = catalogApi;
     _basketApi  = basketApi;
 }
Exemplo n.º 34
0
 public SearchController(ICatalogApi catalogApi)
 {
     _catalogApi = catalogApi;
 }
Exemplo n.º 35
0
 public CheckOutModel(IBasketApi basketApi, ICatalogApi catalogApi)
 {
     this.basketApi  = basketApi ?? throw new ArgumentNullException(nameof(basketApi));
     this.catalogApi = catalogApi ?? throw new ArgumentNullException(nameof(catalogApi));
 }
Exemplo n.º 36
0
 public IndexModel(ICatalogApi catalogApi, IBasketRepository basketRepository)
 {
     _catalogApi       = catalogApi ?? throw new ArgumentNullException(nameof(catalogApi));
     _basketRepository = basketRepository ?? throw new ArgumentNullException(nameof(basketRepository));
 }
Exemplo n.º 37
0
 public IndexModel(ICatalogApi catalogApi, IShopCartApi shopCartApi)
 {
     _catalogApi  = catalogApi ?? throw new ArgumentNullException(nameof(catalogApi));
     _shopCartApi = shopCartApi ?? throw new ArgumentNullException(nameof(shopCartApi));
 }
 public ProductDetailModel(IBasketApi basketApi, ICatalogApi catalogApi)
 {
     this.basketApi  = basketApi ?? throw new ArgumentNullException(nameof(basketApi));
     this.catalogApi = catalogApi ?? throw new ArgumentNullException(nameof(catalogApi));
 }