Пример #1
0
 private void GetDashByDate()
 {
     try
     {
         var madDash     = new PaylessMadCms(_core);
         var forwardDate = GetDateFromRequest();
         _result.resultset = madDash.GetInitData(forwardDate);
     }
     catch (Exception)
     {
         // ignored
     }
 }
Пример #2
0
 private void Update_MenuBy_CmsAndFtpFile(Response <MenuResponse> result)
 {
     try
     {
         var madDash = new PaylessMadCms(_core);
         var categoryImagesLookup = madDash.CategoryImages();
         var hrefLookup           = HrefLookup.Load(_core);
         if (_errors.Any() || !result.resultset.Menu.Any())
         {
             return;
         }
         Update_MenuHrefLookup(result.resultset.Menu, categoryImagesLookup, hrefLookup);
         Add_MenuItem_GiftCard(result);
         Add_MenuItem_Help(result);
     }
     catch (Exception ex)
     {
         _errors.Add(ex.Handle("Menu.Update_MenuBy_CmsAndFtpFile", ErrorSeverity.FollowUp, ErrorType.RequestError));
     }
 }
Пример #3
0
        public IResponseBase Execute(IRequestParameter parameters)
        {
            var result = new Response <CategoryResponse>();

            try
            {
                _request = (CategoryRequest)parameters;
                var hrefLookup = HrefLookup.Load(_core);
                var catid      = hrefLookup.Forward.Get(ParsingHelper.GetHrefWithoutQueryString(_request.Href));
                var cacheKey   = string.Format(Config.CacheKeys.Category, catid);

                result = CacheMemory.Get <Response <CategoryResponse> >(cacheKey);
                if (result == null || string.IsNullOrWhiteSpace(result.resultset.CategoryID))
                {
                    var forwardDate = GetDateFromRequest();
                    var maddash     = new PaylessMadCms(_core);
                    result.resultset = maddash.GetCategoryData(catid, forwardDate);
                    var config      = BuildAPIConfig(parameters, catid);
                    var apiResponse = DWClient.GetAPIResponse <ProductSearchResult>(config);
                    if (apiResponse.ResponseStatus.Code == HttpStatusCode.OK)
                    {
                        result.resultset.Filters = new ExtendedFilter(apiResponse.Model.Refinements, null, hrefLookup);
                    }

                    result.resultset.CategoryID = catid;
                    if (result.errors.Count == 0)
                    {
                        CacheMemory.SetAndExpiresHoursAsync(cacheKey, result, 1);
                    }
                }
            }
            catch (Exception ex)
            {
                _errors.Add(ex.Handle("Category.Execute", ErrorSeverity.FollowUp, ErrorType.RequestError));
            }
            return(result);
        }
Пример #4
0
        public Product(DWProduct product, string color, ICore _core, List <SiteError> errors) : this()
        {
            AdditionalInfo   = product.CustomerService;
            CareInstructions = product.CareInstructions;
            Description      = product.ShortDescription;
            Name             = product.Name;
            Brand            = product.Brand;
            Category         = product.PrimaryCategoryId ?? "";
            ProductId        = product.Id;
            ProductFlags     = LookupCallouts(product.ProductFlags);
            Promotions       = product.Promotions.Where(a => !string.IsNullOrEmpty(a.Callout)).ToList();
            IsInStore        = product.IsInStore == null || product.IsInStore == true;


            if (!string.IsNullOrEmpty(product.PrimaryCategoryId))
            {
                BreadCrumb = RecommendedProducts.Load(product.Id, _core).Breadcrumb;
            }

            var price = new Price(product.Price.ToString(CultureInfo.InvariantCulture));

            if (product.Price == 0 && product.Variants != null)
            {
                price = new Price(product.Variants[0].Price.ToString());
            }

            if (product.MaxPrice > 0)
            {
                var maxPrice = new Price(product.MaxPrice.ToString());
                price.Label = maxPrice.Formatted;
            }
            Pricing.Add(price);
            Image = new Image {
                Title = product.Brand
            };
            if (!string.IsNullOrEmpty(product.DisplayBrand))
            {
                var cms         = new PaylessMadCms(_core);
                var brandImages = cms.BrandImageLookup();
                if (brandImages.ContainsKey(product.DisplayBrand))
                {
                    var brandImage = brandImages[product.DisplayBrand];
                    Image.Src = string.Format(Config.Urls.BrandImageTemplate, brandImage);
                }
            }

            var variants = product.Variants;

            if (variants != null)
            {
                VariantIdsSegments = variants.Select((x, i) => new { x, i })
                                     .GroupBy(x => x.i / 50)
                                     .Select(x => string.Join(",", x.Select(y => y.x.ProductId)))
                                     .ToList();

                AvailableVariations = product.VariationAttributes;

                var isGiftCard = product.Brand != null && product.Brand == "GIFT CARD";
                if (AvailableVariations != null)
                {
                    var sizeVariations = AvailableVariations.Find(x => x.Id == "size" && x.Values.Any());
                    var isOneSizeOnly  = (sizeVariations != null &&
                                          sizeVariations.Values.Count.Equals(1) &&
                                          sizeVariations.Values.First().Name == "One Size") ||
                                         (sizeVariations == null);


                    if (product.ImageGroups != null)
                    {
                        var imageGroups = product.ImageGroups;

                        var swatchImages    = DwSwatchImages(imageGroups);
                        var colorVariations = DWColorVariationAttribute();
                        SetSelectedColorValue(color, colorVariations, swatchImages, imageGroups, variants, isOneSizeOnly,
                                              isGiftCard);

                        var designVariations = DwDesignVariationAttribute();
                        if (designVariations != null)
                        {
                            DWGetDesignValues(designVariations, imageGroups, variants);

                            if (Designs.Any())
                            {
                                var firstOrDefault = Designs.FirstOrDefault();
                                if (firstOrDefault != null)
                                {
                                    firstOrDefault.IsSelected = true;
                                }
                            }
                        }
                    }
                }
            }

            DwSetProductRating(_core, product);
            VideoID = product.InvodoVideoExists ? ProductId : null;
        }