//private readonly IStoreContext _storeContext;
        //private readonly IDiscountService _discountService;
        //private readonly ICategoryService _categoryService;
        //private readonly IProductAttributeParser _productAttributeParser;
        //private readonly IProductService _productService;
        //private readonly ICacheManager _cacheManager;
        //private readonly ShoppingCartSettings _shoppingCartSettings;
        //private readonly CatalogSettings _catalogSettings;

        #endregion

        #region constructor

        public PromosPriceCalculationService(
            IPromoUtilities promoUtilities,
            IWorkContext workContext,
            IStoreContext storeContext,
            IDiscountService discountService,
            ICategoryService categoryService,
            IManufacturerService manufacturerService,
            IProductAttributeParser productAttributeParser,
            IProductService productService,
            ICacheManager cacheManager,
            ShoppingCartSettings shoppingCartSettings,
            CatalogSettings catalogSettings,
            PromoSettings promoSettings,
            ICurrencyService currencyService,
            IPriceCalculationService priceCalculationService,
            ILocalizationService localizationService,
            ILogger logger)
            : base (workContext, storeContext, discountService,
                    categoryService, manufacturerService, productAttributeParser,
                    productService, cacheManager, shoppingCartSettings,
                    catalogSettings)
        {
            this._promoUtilities = promoUtilities;
            this._promoSettings = promoSettings;
            this._workContext = workContext;
            this._currencyService = currencyService;
            this._priceCalculationService = priceCalculationService;
            this._localizationService = localizationService;
            this._logger = logger;
        }
 public MobSocialMessageService(IMessageTemplateService messageTemplateService,
                                    IStoreService storeService, IMessageTokenProvider messageTokenProvider,
                                    ILanguageService languageService,
                                    IStoreContext storeContext,
                                    IEventPublisher eventPublisher,
                                    ITokenizer tokenizer, IQueuedEmailService queuedEmailService,
                                    IEmailAccountService emailAccountService,
                                    EmailAccountSettings emailAccountSettings,
                                    ILocalizationService localizationService,
                                    MessageTemplatesSettings messageTemplateSettings,
                                    CatalogSettings catalogSettings,
                                    IProductAttributeParser productAttributeParser, IWorkContext workContext)
 {
     _messageTemplateService = messageTemplateService;
     _storeService = storeService;
     _messageTokenProvider = messageTokenProvider;
     _languageService = languageService;
     _storeContext = storeContext;
     _eventPublisher = eventPublisher;
     _tokenizer = tokenizer;
     _queuedEmailService = queuedEmailService;
     _emailAccountService = emailAccountService;
     _emailAccountSettings = emailAccountSettings;
     _localizationService = localizationService;
     _messageTemplateSettings = messageTemplateSettings;
     _catalogSettings = catalogSettings;
     _productAttributeParser = productAttributeParser;
     _workContext = workContext;
 }
        public MessageTokenProvider(ILanguageService languageService,
            ILocalizationService localizationService,
            IDateTimeHelper dateTimeHelper,
            IPriceFormatter priceFormatter,
            ICurrencyService currencyService,
            IWorkContext workContext,
            IDownloadService downloadService,
            IOrderService orderService,
            IPaymentService paymentService,
            IStoreService storeService,
            IStoreContext storeContext,
            IProductAttributeParser productAttributeParser,
            IAddressAttributeFormatter addressAttributeFormatter,
            MessageTemplatesSettings templatesSettings,
            CatalogSettings catalogSettings,
            TaxSettings taxSettings,
            CurrencySettings currencySettings,
            ShippingSettings shippingSettings,
            IEventPublisher eventPublisher,
            PromoSettings promoSettings,
            IPromoOrderService promoOrderService
            )
            : base(languageService, localizationService,
            dateTimeHelper, priceFormatter, currencyService, workContext,
            downloadService, orderService, paymentService, storeService,
            storeContext, productAttributeParser,
            addressAttributeFormatter, templatesSettings, catalogSettings,
            taxSettings, currencySettings, shippingSettings, eventPublisher)
        {
            this._languageService = languageService;
            this._localizationService = localizationService;
            this._dateTimeHelper = dateTimeHelper;
            this._priceFormatter = priceFormatter;
            this._currencyService = currencyService;
            this._workContext = workContext;
            this._downloadService = downloadService;
            this._orderService = orderService;
            this._paymentService = paymentService;
            this._productAttributeParser = productAttributeParser;
            this._addressAttributeFormatter = addressAttributeFormatter;
            this._storeService = storeService;
            this._storeContext = storeContext;

            this._templatesSettings = templatesSettings;
            this._catalogSettings = catalogSettings;
            this._taxSettings = taxSettings;
            this._currencySettings = currencySettings;
            this._shippingSettings = shippingSettings;
            this._eventPublisher = eventPublisher;

            this._promoSettings = promoSettings;
            this._promoOrderService = promoOrderService;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get collection of web services for given catalogSettings.
        /// </summary>
        /// <param name="catalogSettings">Catalog settings</param>
        /// <returns>Collection of web services.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="catalogSettings"/> should be not null.</exception>
        /// <exception cref="Exception">Any exception may raised during load process.</exception>
        public static IEnumerable<WebServiceNode> GetWebServices(CatalogSettings catalogSettings)
        {
            if (catalogSettings == null) throw new ArgumentNullException("catalogSettings");

            IWebServicesList webServicesList;
            switch (catalogSettings.TypeOfCatalog)
            {
                case TypeOfCatalog.HisCentral:
                    webServicesList = new HisCentralWebServicesList(catalogSettings.HISCentralUrl);
                    break;
                case TypeOfCatalog.LocalMetadataCache:
                    webServicesList = new DbWebServicesList();
                    break;
                default:
                    throw new Exception("Unsupported TypeOfCatalog");
            }

            return webServicesList.GetWebServices();
        }
Exemplo n.º 5
0
        public static IOntologyReader GetKeywordsList(CatalogSettings catalogSettings)
        {
            if (catalogSettings == null) throw new ArgumentNullException("catalogSettings");

            IOntologyReader reader;
            switch (catalogSettings.TypeOfCatalog)
            {
                case TypeOfCatalog.LocalMetadataCache:
                    reader = new DbKeywordsList();
                    break;
                case TypeOfCatalog.HisCentral:
                    reader = new HisCentralKeywordsList();
                    break;
                default:
                    throw new Exception("Unknown TypeOfCatalog");
            }

            return reader;
        }
Exemplo n.º 6
0
 public static CatalogSettings ToEntity(this CatalogSettingsModel model, CatalogSettings destination)
 {
     return(Mapper.Map(model, destination));
 }
 public ManufacturerFactory(CatalogSettings catalogSettings)
 {
     _catalogSettings = catalogSettings;
 }
Exemplo n.º 8
0
 public CommonModelFactory(BlogSettings blogSettings,
                           CaptchaSettings captchaSettings,
                           CatalogSettings catalogSettings,
                           CommonSettings commonSettings,
                           CustomerSettings customerSettings,
                           DisplayDefaultFooterItemSettings displayDefaultFooterItemSettings,
                           ForumSettings forumSettings,
                           //IActionContextAccessor actionContextAccessor,
                           ICategoryService categoryService,
                           ICurrencyService currencyService,
                           ICustomerService customerService,
                           IForumService forumService,
                           IGenericAttributeService genericAttributeService,
                           IWebHostEnvironment hostingEnvironment,
                           ILanguageService languageService,
                           ILocalizationService localizationService,
                           IManufacturerService manufacturerService,
                           INopFileProvider fileProvider,
                           IPageHeadBuilder pageHeadBuilder,
                           IPermissionService permissionService,
                           IPictureService pictureService,
                           IProductService productService,
                           IProductTagService productTagService,
                           ISitemapGenerator sitemapGenerator,
                           IStaticCacheManager cacheManager,
                           IStoreContext storeContext,
                           IThemeContext themeContext,
                           IThemeProvider themeProvider,
                           ITopicService topicService,
                           IUrlHelperFactory urlHelperFactory,
                           IUrlRecordService urlRecordService,
                           IWebHelper webHelper,
                           IWorkContext workContext,
                           LocalizationSettings localizationSettings,
                           NewsSettings newsSettings,
                           StoreInformationSettings storeInformationSettings,
                           VendorSettings vendorSettings)
 {
     this._blogSettings     = blogSettings;
     this._captchaSettings  = captchaSettings;
     this._catalogSettings  = catalogSettings;
     this._commonSettings   = commonSettings;
     this._customerSettings = customerSettings;
     this._displayDefaultFooterItemSettings = displayDefaultFooterItemSettings;
     this._forumSettings = forumSettings;
     //this._actionContextAccessor = actionContextAccessor;
     this._categoryService         = categoryService;
     this._currencyService         = currencyService;
     this._customerService         = customerService;
     this._forumService            = forumService;
     this._genericAttributeService = genericAttributeService;
     this._hostingEnvironment      = hostingEnvironment;
     this._languageService         = languageService;
     this._localizationService     = localizationService;
     this._manufacturerService     = manufacturerService;
     this._fileProvider            = fileProvider;
     this._pageHeadBuilder         = pageHeadBuilder;
     this._permissionService       = permissionService;
     this._pictureService          = pictureService;
     this._productService          = productService;
     this._productTagService       = productTagService;
     this._sitemapGenerator        = sitemapGenerator;
     this._cacheManager            = cacheManager;
     this._storeContext            = storeContext;
     this._themeContext            = themeContext;
     this._themeProvider           = themeProvider;
     this._topicService            = topicService;
     this._urlHelperFactory        = urlHelperFactory;
     this._urlRecordService        = urlRecordService;
     this._webHelper                = webHelper;
     this._workContext              = workContext;
     this._localizationSettings     = localizationSettings;
     this._newsSettings             = newsSettings;
     this._storeInformationSettings = storeInformationSettings;
     this._vendorSettings           = vendorSettings;
 }
Exemplo n.º 9
0
 public UriCompser(CatalogSettings catalogSettings)
 {
     this.catalogSettings = catalogSettings;
 }
Exemplo n.º 10
0
 public ProductModelFactory(IModelMapper modelMapper, IMediaAccountant mediaAccountant, CatalogSettings catalogSettings, IPriceAccountant priceAccountant, TaxSettings taxSettings, IRoundingService roundingService)
 {
     _modelMapper     = modelMapper;
     _mediaAccountant = mediaAccountant;
     _catalogSettings = catalogSettings;
     _priceAccountant = priceAccountant;
     _taxSettings     = taxSettings;
     _roundingService = roundingService;
 }
Exemplo n.º 11
0
 public OrderModelFactory(AddressSettings addressSettings,
                          CatalogSettings catalogSettings,
                          IAddressModelFactory addressModelFactory,
                          IAddressService addressService,
                          ICountryService countryService,
                          ICurrencyService currencyService,
                          ICustomerService customerService,
                          IDateTimeHelper dateTimeHelper,
                          IGiftCardService giftCardService,
                          ILocalizationService localizationService,
                          IOrderProcessingService orderProcessingService,
                          IOrderService orderService,
                          IOrderTotalCalculationService orderTotalCalculationService,
                          IPaymentPluginManager paymentPluginManager,
                          IPaymentService paymentService,
                          IPriceFormatter priceFormatter,
                          IProductService productService,
                          IRewardPointService rewardPointService,
                          IShipmentService shipmentService,
                          IStateProvinceService stateProvinceService,
                          IStoreContext storeContext,
                          IUrlRecordService urlRecordService,
                          IVendorService vendorService,
                          IWorkContext workContext,
                          OrderSettings orderSettings,
                          PdfSettings pdfSettings,
                          RewardPointsSettings rewardPointsSettings,
                          ShippingSettings shippingSettings,
                          TaxSettings taxSettings,
                          VendorSettings vendorSettings)
 {
     _addressSettings              = addressSettings;
     _catalogSettings              = catalogSettings;
     _addressModelFactory          = addressModelFactory;
     _addressService               = addressService;
     _countryService               = countryService;
     _currencyService              = currencyService;
     _customerService              = customerService;
     _dateTimeHelper               = dateTimeHelper;
     _giftCardService              = giftCardService;
     _localizationService          = localizationService;
     _orderProcessingService       = orderProcessingService;
     _orderService                 = orderService;
     _orderTotalCalculationService = orderTotalCalculationService;
     _paymentPluginManager         = paymentPluginManager;
     _paymentService               = paymentService;
     _priceFormatter               = priceFormatter;
     _productService               = productService;
     _rewardPointService           = rewardPointService;
     _shipmentService              = shipmentService;
     _stateProvinceService         = stateProvinceService;
     _storeContext                 = storeContext;
     _urlRecordService             = urlRecordService;
     _vendorService                = vendorService;
     _workContext          = workContext;
     _orderSettings        = orderSettings;
     _pdfSettings          = pdfSettings;
     _rewardPointsSettings = rewardPointsSettings;
     _shippingSettings     = shippingSettings;
     _taxSettings          = taxSettings;
     _vendorSettings       = vendorSettings;
 }
Exemplo n.º 12
0
 public HomePageBottom(ICatalogModelFactory catalogModelFactory,
                       CatalogSettings catalogSettings)
 {
     this._catalogModelFactory = catalogModelFactory;
     this._catalogSettings     = catalogSettings;
 }
Exemplo n.º 13
0
        public static IEnumerable <ProductOverviewModel> PrepareProductOverviewModels(this Controller controller,
                                                                                      IWorkContext workContext,
                                                                                      IStoreContext storeContext,
                                                                                      ICategoryService categoryService,
                                                                                      IProductService productService,
                                                                                      ISpecificationAttributeService specificationAttributeService,
                                                                                      IPriceCalculationService priceCalculationService,
                                                                                      IPriceFormatter priceFormatter,
                                                                                      IPermissionService permissionService,
                                                                                      ILocalizationService localizationService,
                                                                                      ITaxService taxService,
                                                                                      ICurrencyService currencyService,
                                                                                      IPictureService pictureService,
                                                                                      IWebHelper webHelper,
                                                                                      ICacheManager cacheManager,
                                                                                      CatalogSettings catalogSettings,
                                                                                      MediaSettings mediaSettings,
                                                                                      IEnumerable <Product> products,
                                                                                      bool preparePriceModel                 = true, bool preparePictureModel = true,
                                                                                      int?productThumbPictureSize            = null, bool prepareSpecificationAttributes = false,
                                                                                      bool forceRedirectionAfterAddingToCart = false)
        {
            if (products == null)
            {
                throw new ArgumentNullException("products");
            }

            var models = new List <ProductOverviewModel>();

            foreach (var product in products)
            {
                var model = new ProductOverviewModel
                {
                    Id               = product.Id,
                    Name             = product.GetLocalized(x => x.Name),
                    ShortDescription = product.GetLocalized(x => x.ShortDescription),
                    FullDescription  = product.GetLocalized(x => x.FullDescription),
                    SeName           = product.GetSeName(),
                };
                //price
                if (preparePriceModel)
                {
                    #region Prepare product price

                    var priceModel = new ProductOverviewModel.ProductPriceModel
                    {
                        ForceRedirectionAfterAddingToCart = forceRedirectionAfterAddingToCart
                    };

                    switch (product.ProductType)
                    {
                    case ProductType.GroupedProduct:
                    {
                        #region Grouped product

                        var associatedProducts = productService.GetAssociatedProducts(product.Id, storeContext.CurrentStore.Id);

                        switch (associatedProducts.Count)
                        {
                        case 0:
                        {
                            //no associated products
                            priceModel.OldPrice              = null;
                            priceModel.Price                 = null;
                            priceModel.DisableBuyButton      = true;
                            priceModel.DisableWishlistButton = true;
                            priceModel.AvailableForPreOrder  = false;
                        }
                        break;

                        default:
                        {
                            //we have at least one associated product
                            priceModel.DisableBuyButton      = true;
                            priceModel.DisableWishlistButton = true;
                            priceModel.AvailableForPreOrder  = false;

                            if (permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
                            {
                                //find a minimum possible price
                                decimal?minPossiblePrice = null;
                                Product minPriceProduct  = null;
                                foreach (var associatedProduct in associatedProducts)
                                {
                                    //calculate for the maximum quantity (in case if we have tier prices)
                                    var tmpPrice = priceCalculationService.GetFinalPrice(associatedProduct,
                                                                                         workContext.CurrentCustomer, decimal.Zero, true, int.MaxValue);
                                    if (!minPossiblePrice.HasValue || tmpPrice < minPossiblePrice.Value)
                                    {
                                        minPriceProduct  = associatedProduct;
                                        minPossiblePrice = tmpPrice;
                                    }
                                }
                                if (minPriceProduct != null && !minPriceProduct.CustomerEntersPrice)
                                {
                                    if (minPriceProduct.CallForPrice)
                                    {
                                        priceModel.OldPrice = null;
                                        priceModel.Price    = localizationService.GetResource("Products.CallForPrice");
                                    }
                                    else if (minPossiblePrice.HasValue)
                                    {
                                        //calculate prices
                                        decimal taxRate;
                                        decimal finalPriceBase = taxService.GetProductPrice(minPriceProduct, minPossiblePrice.Value, out taxRate);
                                        decimal finalPrice     = currencyService.ConvertFromPrimaryStoreCurrency(finalPriceBase, workContext.WorkingCurrency);

                                        priceModel.OldPrice = null;
                                        priceModel.Price    = String.Format(localizationService.GetResource("Products.PriceRangeFrom"), priceFormatter.FormatPrice(finalPrice));
                                    }
                                    else
                                    {
                                        //Actually it's not possible (we presume that minimalPrice always has a value)
                                        //We never should get here
                                        Debug.WriteLine("Cannot calculate minPrice for product #{0}", product.Id);
                                    }
                                }
                            }
                            else
                            {
                                //hide prices
                                priceModel.OldPrice = null;
                                priceModel.Price    = null;
                            }
                        }
                        break;
                        }

                        #endregion
                    }
                    break;

                    case ProductType.SimpleProduct:
                    default:
                    {
                        #region Simple product

                        //add to cart button
                        priceModel.DisableBuyButton = product.DisableBuyButton ||
                                                      !permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart) ||
                                                      !permissionService.Authorize(StandardPermissionProvider.DisplayPrices);

                        //add to wishlist button
                        priceModel.DisableWishlistButton = product.DisableWishlistButton ||
                                                           !permissionService.Authorize(StandardPermissionProvider.EnableWishlist) ||
                                                           !permissionService.Authorize(StandardPermissionProvider.DisplayPrices);

                        //rental
                        priceModel.IsRental = product.IsRental;

                        //pre-order
                        if (product.AvailableForPreOrder)
                        {
                            priceModel.AvailableForPreOrder = !product.PreOrderAvailabilityStartDateTimeUtc.HasValue ||
                                                              product.PreOrderAvailabilityStartDateTimeUtc.Value >= DateTime.UtcNow;
                            priceModel.PreOrderAvailabilityStartDateTimeUtc = product.PreOrderAvailabilityStartDateTimeUtc;
                        }

                        //prices
                        if (permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
                        {
                            //calculate for the maximum quantity (in case if we have tier prices)
                            decimal minPossiblePrice = priceCalculationService.GetFinalPrice(product,
                                                                                             workContext.CurrentCustomer, decimal.Zero, true, int.MaxValue);
                            if (!product.CustomerEntersPrice)
                            {
                                if (product.CallForPrice)
                                {
                                    //call for price
                                    priceModel.OldPrice = null;
                                    priceModel.Price    = localizationService.GetResource("Products.CallForPrice");
                                }
                                else
                                {
                                    //calculate prices
                                    decimal taxRate;
                                    decimal oldPriceBase   = taxService.GetProductPrice(product, product.OldPrice, out taxRate);
                                    decimal finalPriceBase = taxService.GetProductPrice(product, minPossiblePrice, out taxRate);

                                    decimal oldPrice   = currencyService.ConvertFromPrimaryStoreCurrency(oldPriceBase, workContext.WorkingCurrency);
                                    decimal finalPrice = currencyService.ConvertFromPrimaryStoreCurrency(finalPriceBase, workContext.WorkingCurrency);

                                    //do we have tier prices configured?
                                    var tierPrices = new List <TierPrice>();
                                    if (product.HasTierPrices)
                                    {
                                        tierPrices.AddRange(product.TierPrices
                                                            .OrderBy(tp => tp.Quantity)
                                                            .ToList()
                                                            .FilterByStore(storeContext.CurrentStore.Id)
                                                            .FilterForCustomer(workContext.CurrentCustomer)
                                                            .RemoveDuplicatedQuantities());
                                    }
                                    //When there is just one tier (with  qty 1),
                                    //there are no actual savings in the list.
                                    bool displayFromMessage = tierPrices.Count > 0 &&
                                                              !(tierPrices.Count == 1 && tierPrices[0].Quantity <= 1);
                                    if (displayFromMessage)
                                    {
                                        priceModel.OldPrice = null;
                                        priceModel.Price    = String.Format(localizationService.GetResource("Products.PriceRangeFrom"), priceFormatter.FormatPrice(finalPrice));
                                    }
                                    else
                                    {
                                        if (finalPriceBase != oldPriceBase && oldPriceBase != decimal.Zero)
                                        {
                                            priceModel.OldPrice = priceFormatter.FormatPrice(oldPrice);
                                            priceModel.Price    = priceFormatter.FormatPrice(finalPrice);
                                        }
                                        else
                                        {
                                            priceModel.OldPrice = null;
                                            priceModel.Price    = priceFormatter.FormatPrice(finalPrice);
                                        }
                                    }
                                    if (product.IsRental)
                                    {
                                        //rental product
                                        priceModel.OldPrice = priceFormatter.FormatRentalProductPeriod(product, priceModel.OldPrice);
                                        priceModel.Price    = priceFormatter.FormatRentalProductPeriod(product, priceModel.Price);
                                    }


                                    //property for German market
                                    //we display tax/shipping info only with "shipping enabled" for this product
                                    //we also ensure this it's not free shipping
                                    priceModel.DisplayTaxShippingInfo = catalogSettings.DisplayTaxShippingInfoProductBoxes &&
                                                                        product.IsShipEnabled &&
                                                                        !product.IsFreeShipping;
                                }
                            }
                        }
                        else
                        {
                            //hide prices
                            priceModel.OldPrice = null;
                            priceModel.Price    = null;
                        }

                        #endregion
                    }
                    break;
                    }

                    model.ProductPrice = priceModel;

                    #endregion
                }

                //picture
                if (preparePictureModel)
                {
                    #region Prepare product picture

                    //If a size has been set in the view, we use it in priority
                    int pictureSize = productThumbPictureSize.HasValue ? productThumbPictureSize.Value : mediaSettings.ProductThumbPictureSize;
                    //prepare picture model
                    var defaultProductPictureCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_DEFAULTPICTURE_MODEL_KEY, product.Id, pictureSize, true, workContext.WorkingLanguage.Id, webHelper.IsCurrentConnectionSecured(), storeContext.CurrentStore.Id);
                    model.DefaultPictureModel = cacheManager.Get(defaultProductPictureCacheKey, () =>
                    {
                        var picture      = pictureService.GetPicturesByProductId(product.Id, 1).FirstOrDefault();
                        var pictureModel = new PictureModel
                        {
                            ImageUrl         = pictureService.GetPictureUrl(picture, pictureSize),
                            FullSizeImageUrl = pictureService.GetPictureUrl(picture),
                            Title            = string.Format(localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
                            AlternateText    = string.Format(localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name)
                        };
                        return(pictureModel);
                    });

                    #endregion
                }

                //specs
                if (prepareSpecificationAttributes)
                {
                    model.SpecificationAttributeModels = PrepareProductSpecificationModel(controller, workContext,
                                                                                          specificationAttributeService, cacheManager, product);
                }

                //reviews
                model.ReviewOverviewModel = new ProductReviewOverviewModel
                {
                    ProductId            = product.Id,
                    RatingSum            = product.ApprovedRatingSum,
                    TotalReviews         = product.ApprovedTotalReviews,
                    AllowCustomerReviews = product.AllowCustomerReviews
                };

                models.Add(model);
            }
            return(models);
        }
Exemplo n.º 14
0
 public FilterController(IFilterService filterService, CatalogSettings catalogSettings)
 {
     _filterService   = filterService;
     _catalogSettings = catalogSettings;
 }
Exemplo n.º 15
0
        public new void SetUp()
        {
            _pictureService                = new Mock <IPictureService>();
            _authenticationService         = new Mock <IAuthenticationService>();
            _vendorService                 = new Mock <IVendorService>();
            _productTemplateService        = new Mock <IProductTemplateService>();
            _dateRangeService              = new Mock <IDateRangeService>();
            _storeService                  = new Mock <IStoreService>();
            _productAttributeService       = new Mock <IProductAttributeService>();
            _productTagService             = new Mock <IProductTagService>();
            _taxCategoryService            = new Mock <ITaxCategoryService>();
            _measureService                = new Mock <IMeasureService>();
            _catalogSettings               = new CatalogSettings();
            _specificationAttributeService = new Mock <ISpecificationAttributeService>();
            _orderSettings                 = new OrderSettings();
            _categoryService               = new Mock <ICategoryService>();
            _manufacturerService           = new Mock <IManufacturerService>();
            _customerService               = new Mock <ICustomerService>();
            _newsLetterSubscriptionService = new Mock <INewsLetterSubscriptionService>();
            _productEditorSettings         = new ProductEditorSettings();
            _customerAttributeFormatter    = new Mock <ICustomerAttributeFormatter>();

            _orderService         = new Mock <IOrderService>();
            _countryService       = new Mock <ICountryService>();
            _stateProvinceService = new Mock <IStateProvinceService>();
            _priceFormatter       = new Mock <IPriceFormatter>();
            _forumSettings        = new ForumSettings();
            _forumService         = new Mock <IForumService>();
            _gdprService          = new Mock <IGdprService>();
            _customerSettings     = new CustomerSettings();
            _dateTimeHelper       = new Mock <IDateTimeHelper>();
            _addressSettings      = new AddressSettings();
            _currencyService      = new Mock <ICurrencyService>();
            _urlRecordService     = new Mock <IUrlRecordService>();
            _feeSerivce           = new Mock <IFeeService>();

            var nopEngine = new Mock <NopEngine>();

            var picture = new Picture
            {
                Id          = 1,
                SeoFilename = "picture"
            };

            _authenticationService.Setup(p => p.GetAuthenticatedCustomer()).Returns(GetTestCustomer());
            _pictureService.Setup(p => p.GetPictureById(1)).Returns(picture);
            _pictureService.Setup(p => p.GetThumbLocalPath(picture, 0, true)).Returns(@"c:\temp\picture.png");
            _pictureService.Setup(p => p.GetPicturesByProductId(1, 3)).Returns(new List <Picture> {
                picture
            });
            _productTemplateService.Setup(p => p.GetAllProductTemplates()).Returns(new List <ProductTemplate> {
                new ProductTemplate {
                    Id = 1
                }
            });
            _dateRangeService.Setup(d => d.GetAllDeliveryDates()).Returns(new List <DeliveryDate> {
                new DeliveryDate {
                    Id = 1
                }
            });
            _dateRangeService.Setup(d => d.GetAllProductAvailabilityRanges()).Returns(new List <ProductAvailabilityRange> {
                new ProductAvailabilityRange {
                    Id = 1
                }
            });
            _taxCategoryService.Setup(t => t.GetAllTaxCategories()).Returns(new List <TaxCategory> {
                new TaxCategory()
            });
            _vendorService.Setup(v => v.GetAllVendors(string.Empty, 0, int.MaxValue, true)).Returns(new PagedList <Vendor>(new List <Vendor> {
                new Vendor {
                    Id = 1
                }
            }, 0, 10));
            _measureService.Setup(m => m.GetAllMeasureWeights()).Returns(new List <MeasureWeight> {
                new MeasureWeight()
            });
            _categoryService.Setup(c => c.GetProductCategoriesByProductId(1, true)).Returns(new List <ProductCategory>());
            _manufacturerService.Setup(m => m.GetProductManufacturersByProductId(1, true)).Returns(new List <ProductManufacturer>());

            var serviceProvider = new TestServiceProvider();

            nopEngine.Setup(x => x.ServiceProvider).Returns(serviceProvider);

            EngineContext.Replace(nopEngine.Object);

            _exportManager = new ExportManager(_addressSettings,
                                               _catalogSettings,
                                               _customerSettings,
                                               _forumSettings,
                                               _categoryService.Object,
                                               _countryService.Object,
                                               _currencyService.Object,
                                               _customerAttributeFormatter.Object,
                                               _customerService.Object,
                                               _dateRangeService.Object,
                                               _dateTimeHelper.Object,
                                               _forumService.Object,
                                               _gdprService.Object,
                                               serviceProvider.GenericAttributeService.Object,
                                               serviceProvider.LocalizationService.Object,
                                               _manufacturerService.Object,
                                               _measureService.Object,
                                               _newsLetterSubscriptionService.Object,
                                               _orderService.Object,
                                               _pictureService.Object,
                                               _priceFormatter.Object,
                                               _productAttributeService.Object,
                                               _productTagService.Object,
                                               _productTemplateService.Object,
                                               _specificationAttributeService.Object,
                                               _stateProvinceService.Object,
                                               _storeService.Object,
                                               _taxCategoryService.Object,
                                               _urlRecordService.Object,
                                               _vendorService.Object,
                                               serviceProvider.WorkContext.Object,
                                               _orderSettings,
                                               _productEditorSettings,
                                               _feeSerivce.Object);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Refresh WebServices list.
 /// </summary>
 /// <param name="catalogSettings">Catalog settings to use. If null - used current catalog settings.</param>
 public void RefreshWebServices(CatalogSettings catalogSettings = null)
 {
     try
     {
         _webServices = WebServicesReader.GetWebServices(catalogSettings ?? _parent.CatalogSettings).ToList();
     }
     catch (Exception ex)
     {
         //AppContext.Instance.Get<IUserMessage>().Error("Unable to refresh WebServices. Empty list will be used.", ex);
         _webServices = new List<WebServiceNode>();
     }
 }
Exemplo n.º 17
0
        public CommonModelFactory(ICategoryService categoryService,
                                  IProductService productService,
                                  IManufacturerService manufacturerService,
                                  ITopicService topicService,
                                  ILanguageService languageService,
                                  ICurrencyService currencyService,
                                  ILocalizationService localizationService,
                                  IWorkContext workContext,
                                  IStoreContext storeContext,
                                  ISitemapGenerator sitemapGenerator,
                                  IThemeContext themeContext,
                                  IThemeProvider themeProvider,
                                  IForumService forumService,
                                  IGenericAttributeService genericAttributeService,
                                  IWebHelper webHelper,
                                  IPermissionService permissionService,
                                  ICacheManager cacheManager,
                                  IPageHeadBuilder pageHeadBuilder,
                                  IPictureService pictureService,
                                  HttpContextBase httpContext,
                                  CatalogSettings catalogSettings,
                                  StoreInformationSettings storeInformationSettings,
                                  CommonSettings commonSettings,
                                  BlogSettings blogSettings,
                                  NewsSettings newsSettings,
                                  ForumSettings forumSettings,
                                  LocalizationSettings localizationSettings,
                                  CaptchaSettings captchaSettings,
                                  VendorSettings vendorSettings)
        {
            this._categoryService         = categoryService;
            this._productService          = productService;
            this._manufacturerService     = manufacturerService;
            this._topicService            = topicService;
            this._languageService         = languageService;
            this._currencyService         = currencyService;
            this._localizationService     = localizationService;
            this._workContext             = workContext;
            this._storeContext            = storeContext;
            this._sitemapGenerator        = sitemapGenerator;
            this._themeContext            = themeContext;
            this._themeProvider           = themeProvider;
            this._forumservice            = forumService;
            this._genericAttributeService = genericAttributeService;
            this._webHelper         = webHelper;
            this._permissionService = permissionService;
            this._cacheManager      = cacheManager;
            this._pageHeadBuilder   = pageHeadBuilder;
            this._pictureService    = pictureService;
            this._httpContext       = httpContext;

            this._catalogSettings          = catalogSettings;
            this._storeInformationSettings = storeInformationSettings;
            this._commonSettings           = commonSettings;
            this._blogSettings             = blogSettings;
            this._newsSettings             = newsSettings;
            this._forumSettings            = forumSettings;
            this._localizationSettings     = localizationSettings;
            this._captchaSettings          = captchaSettings;
            this._vendorSettings           = vendorSettings;
        }
Exemplo n.º 18
0
 public CatalogHelper(
     SmartDbContext db,
     ICommonServices services,
     IMenuService menuService,
     IManufacturerService manufacturerService,
     IProductService productService,
     //IProductTemplateService productTemplateService,
     IProductAttributeService productAttributeService,
     IProductAttributeMaterializer productAttributeMaterializer,
     IProductAttributeFormatter productAttributeFormatter,
     ITaxService taxService,
     ICurrencyService currencyService,
     IMediaService mediaService,
     IPriceCalculationService priceCalculationService,
     //IPriceFormatter priceFormatter,
     //ISpecificationAttributeService specificationAttributeService,
     IDateTimeHelper dateTimeHelper,
     //IBackInStockSubscriptionService backInStockSubscriptionService,
     IDownloadService downloadService,
     MediaSettings mediaSettings,
     CatalogSettings catalogSettings,
     CustomerSettings customerSettings,
     CaptchaSettings captchaSettings,
     IMeasureService measureService,
     //IQuantityUnitService quantityUnitService,
     MeasureSettings measureSettings,
     TaxSettings taxSettings,
     PerformanceSettings performanceSettings,
     IDeliveryTimeService deliveryTimeService,
     Lazy <IDataExporter> dataExporter,
     ICatalogSearchService catalogSearchService,
     ICatalogSearchQueryFactory catalogSearchQueryFactory,
     IUrlHelper urlHelper,
     ProductUrlHelper productUrlHelper,
     ILocalizedEntityService localizedEntityService,
     IUrlService urlService,
     ILinkResolver linkResolver)
 {
     _db                  = db;
     _services            = services;
     _workContext         = services.WorkContext;
     _storeContext        = services.StoreContext;
     _cache               = services.Cache;
     _menuService         = menuService;
     _manufacturerService = manufacturerService;
     _productService      = productService;
     //_productTemplateService = productTemplateService;
     _productAttributeService      = productAttributeService;
     _productAttributeMaterializer = productAttributeMaterializer;
     _productAttributeFormatter    = productAttributeFormatter;
     _taxService              = taxService;
     _currencyService         = currencyService;
     _mediaService            = mediaService;
     _localizationService     = _services.Localization;
     _priceCalculationService = priceCalculationService;
     //_priceFormatter = priceFormatter;
     //_specificationAttributeService = specificationAttributeService;
     _dateTimeHelper = dateTimeHelper;
     //_backInStockSubscriptionService = backInStockSubscriptionService;
     _downloadService = downloadService;
     _measureService  = measureService;
     //_quantityUnitService = quantityUnitService;
     _measureSettings           = measureSettings;
     _taxSettings               = taxSettings;
     _performanceSettings       = performanceSettings;
     _deliveryTimeService       = deliveryTimeService;
     _mediaSettings             = mediaSettings;
     _catalogSettings           = catalogSettings;
     _customerSettings          = customerSettings;
     _captchaSettings           = captchaSettings;
     _dataExporter              = dataExporter;
     _catalogSearchService      = catalogSearchService;
     _catalogSearchQueryFactory = catalogSearchQueryFactory;
     _urlHelper              = urlHelper;
     _productUrlHelper       = productUrlHelper;
     _localizedEntityService = localizedEntityService;
     _urlService             = urlService;
     _linkResolver           = linkResolver;
     _httpRequest            = _urlHelper.ActionContext.HttpContext.Request;
 }
Exemplo n.º 19
0
 public static CatalogSettingsModel ToModel(this CatalogSettings entity)
 {
     return(entity.MapTo <CatalogSettings, CatalogSettingsModel>());
 }
Exemplo n.º 20
0
 public CategoryViewModelService(ICategoryService categoryService, ICategoryTemplateService categoryTemplateService, IDiscountService discountService,
                                 ILocalizationService localizationService, IStoreService storeService, ICustomerService customerService, IPictureService pictureService,
                                 IUrlRecordService urlRecordService, ICustomerActivityService customerActivityService, IProductService productService, IManufacturerService manufacturerService,
                                 IVendorService vendorService, IDateTimeHelper dateTimeHelper, ILanguageService languageService, CatalogSettings catalogSettings, SeoSettings seoSettings)
 {
     _categoryService         = categoryService;
     _categoryTemplateService = categoryTemplateService;
     _discountService         = discountService;
     _localizationService     = localizationService;
     _storeService            = storeService;
     _customerService         = customerService;
     _urlRecordService        = urlRecordService;
     _customerActivityService = customerActivityService;
     _productService          = productService;
     _pictureService          = pictureService;
     _manufacturerService     = manufacturerService;
     _vendorService           = vendorService;
     _languageService         = languageService;
     _catalogSettings         = catalogSettings;
     _dateTimeHelper          = dateTimeHelper;
     _seoSettings             = seoSettings;
 }
Exemplo n.º 21
0
 public GetShoppingCartHandler(
     ICacheManager cacheManager,
     IPaymentService paymentService,
     IProductService productService,
     IPictureService pictureService,
     IProductAttributeParser productAttributeParser,
     ILocalizationService localizationService,
     ICheckoutAttributeFormatter checkoutAttributeFormatter,
     ICurrencyService currencyService,
     IDiscountService discountService,
     IShoppingCartService shoppingCartService,
     ICheckoutAttributeService checkoutAttributeService,
     IPermissionService permissionService,
     ITaxService taxService,
     IPriceFormatter priceFormatter,
     ICheckoutAttributeParser checkoutAttributeParser,
     IDownloadService downloadService,
     ICountryService countryService,
     IWarehouseService warehouseService,
     IProductAttributeFormatter productAttributeFormatter,
     IPriceCalculationService priceCalculationService,
     IDateTimeHelper dateTimeHelper,
     IVendorService vendorService,
     IMediator mediator,
     MediaSettings mediaSettings,
     OrderSettings orderSettings,
     ShoppingCartSettings shoppingCartSettings,
     CatalogSettings catalogSettings,
     ShippingSettings shippingSettings,
     CommonSettings commonSettings)
 {
     _cacheManager               = cacheManager;
     _paymentService             = paymentService;
     _productService             = productService;
     _pictureService             = pictureService;
     _productAttributeParser     = productAttributeParser;
     _localizationService        = localizationService;
     _checkoutAttributeFormatter = checkoutAttributeFormatter;
     _currencyService            = currencyService;
     _discountService            = discountService;
     _shoppingCartService        = shoppingCartService;
     _checkoutAttributeService   = checkoutAttributeService;
     _permissionService          = permissionService;
     _taxService                = taxService;
     _priceFormatter            = priceFormatter;
     _checkoutAttributeParser   = checkoutAttributeParser;
     _downloadService           = downloadService;
     _countryService            = countryService;
     _warehouseService          = warehouseService;
     _productAttributeFormatter = productAttributeFormatter;
     _priceCalculationService   = priceCalculationService;
     _dateTimeHelper            = dateTimeHelper;
     _vendorService             = vendorService;
     _mediator             = mediator;
     _mediaSettings        = mediaSettings;
     _orderSettings        = orderSettings;
     _shoppingCartSettings = shoppingCartSettings;
     _catalogSettings      = catalogSettings;
     _shippingSettings     = shippingSettings;
     _commonSettings       = commonSettings;
 }
 public OrderTotalCalculationService(IWorkContext workContext,
     IStoreContext storeContext,
     IPromosPriceCalculationService promosPriceCalculationService,
     IPriceCalculationService priceCalculationService,
     ITaxService taxService,
     IShippingService shippingService,
     IPaymentService paymentService,
     ICheckoutAttributeParser checkoutAttributeParser,
     IDiscountService discountService,
     IGiftCardService giftCardService,
     IGenericAttributeService genericAttributeService,
     TaxSettings taxSettings,
     RewardPointsSettings rewardPointsSettings,
     ShippingSettings shippingSettings,
     ShoppingCartSettings shoppingCartSettings,
     CatalogSettings catalogSettings,
     IPromoUtilities promoUtilities,
     PromoSettings promoSettings,
     IPromoService promoService,
     IAttributeValueService attributeValueService,
     ITaxServiceExtensions taxServiceExtensions,
     ICurrencyService currencyService)
     : base(workContext,
         storeContext,
         priceCalculationService,
         taxService,
         shippingService,
         paymentService,
         checkoutAttributeParser,
         discountService,
         giftCardService,
         genericAttributeService,
         taxSettings,
         rewardPointsSettings,
         shippingSettings,
         shoppingCartSettings,
         catalogSettings)
 {
     this._workContext = workContext;
     this._storeContext = storeContext;
     this._promosPriceCalculationService = promosPriceCalculationService;
     this._taxService = taxService;
     this._shippingService = shippingService;
     this._paymentService = paymentService;
     this._checkoutAttributeParser = checkoutAttributeParser;
     this._discountService = discountService;
     this._giftCardService = giftCardService;
     this._genericAttributeService = genericAttributeService;
     this._taxSettings = taxSettings;
     this._rewardPointsSettings = rewardPointsSettings;
     this._shippingSettings = shippingSettings;
     this._shoppingCartSettings = shoppingCartSettings;
     this._catalogSettings = catalogSettings;
     this._promoUtilities = promoUtilities;
     this._promoSettings = promoSettings;
     this._promoService = promoService;
     this._priceCalculationService = priceCalculationService;
     this._attributeValueService = attributeValueService;
     this._taxServiceExtensions = taxServiceExtensions;
     this._currencyService = currencyService;
 }
Exemplo n.º 23
0
 public static CatalogSettings ToEntity(this CatalogSettingsModel model, CatalogSettings destination)
 {
     return(model.MapTo(destination));
 }
Exemplo n.º 24
0
        public static List <CatalogItem> ChangeUriPlaceholder(this List <CatalogItem> items, CatalogSettings settings)
        {
            var baseUri = settings.PicBaseUrl;

            items.ForEach(catalogItem =>
            {
                catalogItem.PictureUri = settings.AzureStorageEnabled
                    ? baseUri + catalogItem.PictureFileName
                    : baseUri.Replace("[0]", catalogItem.Id.ToString());
            });

            return(items);
        }
Exemplo n.º 25
0
        public CommonController(ICategoryService categoryService,
                                IProductService productService,
                                IManufacturerService manufacturerService,
                                ITopicService topicService,
                                ILanguageService languageService,
                                ICurrencyService currencyService,
                                ILocalizationService localizationService,
                                IWorkContext workContext,
                                IStoreContext storeContext,
                                IQueuedEmailService queuedEmailService,
                                IEmailAccountService emailAccountService,
                                ISitemapGenerator sitemapGenerator,
                                IThemeContext themeContext,
                                IThemeProvider themeProvider,
                                IForumService forumService,
                                IGenericAttributeService genericAttributeService,
                                IWebHelper webHelper,
                                IPermissionService permissionService,
                                ICacheManager cacheManager,
                                ICustomerActivityService customerActivityService,
                                IVendorService vendorService,
                                CustomerSettings customerSettings,
                                TaxSettings taxSettings,
                                CatalogSettings catalogSettings,
                                StoreInformationSettings storeInformationSettings,
                                EmailAccountSettings emailAccountSettings,
                                CommonSettings commonSettings,
                                BlogSettings blogSettings,
                                NewsSettings newsSettings,
                                ForumSettings forumSettings,
                                LocalizationSettings localizationSettings,
                                CaptchaSettings captchaSettings,
                                VendorSettings vendorSettings)
        {
            this._categoryService         = categoryService;
            this._productService          = productService;
            this._manufacturerService     = manufacturerService;
            this._topicService            = topicService;
            this._languageService         = languageService;
            this._currencyService         = currencyService;
            this._localizationService     = localizationService;
            this._workContext             = workContext;
            this._storeContext            = storeContext;
            this._queuedEmailService      = queuedEmailService;
            this._emailAccountService     = emailAccountService;
            this._sitemapGenerator        = sitemapGenerator;
            this._themeContext            = themeContext;
            this._themeProvider           = themeProvider;
            this._forumservice            = forumService;
            this._genericAttributeService = genericAttributeService;
            this._webHelper               = webHelper;
            this._permissionService       = permissionService;
            this._cacheManager            = cacheManager;
            this._customerActivityService = customerActivityService;
            this._vendorService           = vendorService;

            this._customerSettings         = customerSettings;
            this._taxSettings              = taxSettings;
            this._catalogSettings          = catalogSettings;
            this._storeInformationSettings = storeInformationSettings;
            this._emailAccountSettings     = emailAccountSettings;
            this._commonSettings           = commonSettings;
            this._blogSettings             = blogSettings;
            this._newsSettings             = newsSettings;
            this._forumSettings            = forumSettings;
            this._localizationSettings     = localizationSettings;
            this._captchaSettings          = captchaSettings;
            this._vendorSettings           = vendorSettings;
        }
Exemplo n.º 26
0
        public ProductController(
            ICommonServices services,
            IManufacturerService manufacturerService,
            IProductService productService,
            IProductAttributeService productAttributeService,
            IProductAttributeParser productAttributeParser,
            ITaxService taxService,
            ICurrencyService currencyService,
            IPictureService pictureService,
            IPriceCalculationService priceCalculationService,
            IPriceFormatter priceFormatter,
            ICustomerContentService customerContentService,
            ICustomerService customerService,
            IShoppingCartService shoppingCartService,
            IRecentlyViewedProductsService recentlyViewedProductsService,
            IProductTagService productTagService,
            IOrderReportService orderReportService,
            IBackInStockSubscriptionService backInStockSubscriptionService,
            IAclService aclService,
            IStoreMappingService storeMappingService,
            MediaSettings mediaSettings,
            SeoSettings seoSettings,
            CatalogSettings catalogSettings,
            ShoppingCartSettings shoppingCartSettings,
            LocalizationSettings localizationSettings,
            CaptchaSettings captchaSettings,
            CatalogHelper helper,
            IDownloadService downloadService,
            ILocalizationService localizationService,
            IBreadcrumb breadcrumb,
            Lazy <PrivacySettings> privacySettings,
            Lazy <TaxSettings> taxSettings,
            IRepository <Category> categoryRepository,
            ICategoryService categoryService

            )
        {
            _services                       = services;
            _manufacturerService            = manufacturerService;
            _productService                 = productService;
            _productAttributeService        = productAttributeService;
            _productAttributeParser         = productAttributeParser;
            _taxService                     = taxService;
            _currencyService                = currencyService;
            _pictureService                 = pictureService;
            _priceCalculationService        = priceCalculationService;
            _priceFormatter                 = priceFormatter;
            _customerContentService         = customerContentService;
            _customerService                = customerService;
            _shoppingCartService            = shoppingCartService;
            _recentlyViewedProductsService  = recentlyViewedProductsService;
            _productTagService              = productTagService;
            _orderReportService             = orderReportService;
            _backInStockSubscriptionService = backInStockSubscriptionService;
            _aclService                     = aclService;
            _storeMappingService            = storeMappingService;
            _mediaSettings                  = mediaSettings;
            _seoSettings                    = seoSettings;
            _catalogSettings                = catalogSettings;
            _shoppingCartSettings           = shoppingCartSettings;
            _localizationSettings           = localizationSettings;
            _captchaSettings                = captchaSettings;
            _helper              = helper;
            _downloadService     = downloadService;
            _localizationService = localizationService;
            _breadcrumb          = breadcrumb;
            _privacySettings     = privacySettings;
            _taxSettings         = taxSettings;
            _categoryRepository  = categoryRepository;
            _categoryService     = categoryService;
        }
Exemplo n.º 27
0
        public new void SetUp()
        {
            _serviceProvider = new TestServiceProvider();
            _store           = new Store {
                Id = 1
            };
            _storeContext = new Mock <IStoreContext>();
            _storeContext.Setup(x => x.CurrentStore).Returns(_store);

            _categoryService = new Mock <ICategoryService>();

            _customerRoleRepository = new Mock <IRepository <CustomerRole> >();
            _customerRoleRepository.Setup(r => r.Table).Returns(GetMockCustomerRoles);

            _customerCustomerRoleMappingRepository = new Mock <IRepository <CustomerCustomerRoleMapping> >();

            var customerCustomerRoleMapping = new List <CustomerCustomerRoleMapping>();

            _customerCustomerRoleMappingRepository.Setup(r => r.Table)
            .Returns(customerCustomerRoleMapping.AsQueryable());

            _customerCustomerRoleMappingRepository.Setup(r => r.Insert(It.IsAny <CustomerCustomerRoleMapping>()))
            .Callback(
                (CustomerCustomerRoleMapping ccrm) => { customerCustomerRoleMapping.Add(ccrm); });

            _customerService = new CustomerService(new CachingSettings(), null, new FakeCacheKeyService(), null, null, null, null,
                                                   null, _customerCustomerRoleMappingRepository.Object, null, _customerRoleRepository.Object, null, null,
                                                   new TestCacheManager(), _storeContext.Object, null);

            _manufacturerService = new Mock <IManufacturerService>();

            _productRepository = new Mock <IRepository <Product> >();
            _productRepository.Setup(p => p.Table).Returns(GetMockProducts);
            _productRepository.Setup(p => p.GetById(It.IsAny <int>()))
            .Returns((int id) => GetMockProducts().FirstOrDefault(p => p.Id == id));

            _tierPriceRepository = new Mock <IRepository <TierPrice> >();
            _tierPriceRepository.Setup(t => t.Table).Returns(GetMockTierPrices);

            _discountProductMappingRepository = new Mock <IRepository <DiscountProductMapping> >();
            _discountProductMappingRepository.Setup(r => r.Table).Returns(GetMockDiscountProductMapping);
            _serviceProvider.DiscountProductMappingRepository.Setup(r => r.Table)
            .Returns(GetMockDiscountProductMapping);

            var shipmentRepository = new Mock <IRepository <Shipment> >();

            _productService = new ProductService(new CatalogSettings(), new CommonSettings(), null, new FakeCacheKeyService(), _customerService,
                                                 null, null, null, null, null, null, null, null, null, _discountProductMappingRepository.Object,
                                                 _productRepository.Object, null, null, null, null, null, null, null, null, shipmentRepository.Object,
                                                 null, null, _tierPriceRepository.Object, null,
                                                 null, null, null, null, new LocalizationSettings());

            _productAttributeParser = new Mock <IProductAttributeParser>();

            _catalogSettings = new CatalogSettings();

            _staticCacheManager = new TestCacheManager();
            _workContext        = new Mock <IWorkContext>();

            _discountService = TestDiscountService.Init(
                new List <Discount>
            {
                _mockDiscount
            }.AsQueryable(),
                new List <DiscountProductMapping>
            {
                new DiscountProductMapping
                {
                    DiscountId = 1,
                    EntityId   = 1
                }
            }.AsQueryable());

            _priceCalcService = new PriceCalculationService(_catalogSettings,
                                                            new CurrencySettings {
                PrimaryStoreCurrencyId = 1
            },
                                                            new FakeCacheKeyService(), _categoryService.Object,
                                                            _serviceProvider.CurrencyService.Object, _customerService, _discountService,
                                                            _manufacturerService.Object, _productAttributeParser.Object,
                                                            _productService, _staticCacheManager, _storeContext.Object, _workContext.Object);

            var nopEngine = new Mock <NopEngine>();

            nopEngine.Setup(x => x.ServiceProvider).Returns(_serviceProvider);
            EngineContext.Replace(nopEngine.Object);
        }
Exemplo n.º 28
0
 public FakeProductService(CatalogSettings catalogSettings                                                 = null,
                           CommonSettings commonSettings                                                   = null,
                           IAclService aclService                                                          = null,
                           ICustomerService customerService                                                = null,
                           INopDataProvider dataProvider                                                   = null,
                           IDateRangeService dateRangeService                                              = null,
                           IEventPublisher eventPublisher                                                  = null,
                           ILanguageService languageService                                                = null,
                           ILocalizationService localizationService                                        = null,
                           IProductAttributeParser productAttributeParser                                  = null,
                           IProductAttributeService productAttributeService                                = null,
                           IRepository <AclRecord> aclRepository                                           = null,
                           IRepository <CrossSellProduct> crossSellProductRepository                       = null,
                           IRepository <DiscountProductMapping> discountProductMappingRepository           = null,
                           IRepository <Product> productRepository                                         = null,
                           IRepository <ProductAttributeCombination> productAttributeCombinationRepository = null,
                           IRepository <ProductAttributeMapping> productAttributeMappingRepository         = null,
                           IRepository <ProductCategory> productCategoryRepository                         = null,
                           IRepository <ProductPicture> productPictureRepository                           = null,
                           IRepository <ProductReview> productReviewRepository                             = null,
                           IRepository <ProductReviewHelpfulness> productReviewHelpfulnessRepository       = null,
                           IRepository <ProductWarehouseInventory> productWarehouseInventoryRepository     = null,
                           IRepository <RelatedProduct> relatedProductRepository                           = null,
                           IRepository <Shipment> shipmentRepository                                       = null,
                           IRepository <StockQuantityHistory> stockQuantityHistoryRepository               = null,
                           IRepository <StoreMapping> storeMappingRepository                               = null,
                           IRepository <TierPrice> tierPriceRepository                                     = null,
                           IRepository <Warehouse> warehouseRepository                                     = null,
                           IStaticCacheManager staticCacheManager                                          = null,
                           IStoreService storeService                                                      = null,
                           IStoreMappingService storeMappingService                                        = null,
                           IWorkContext workContext                                                        = null,
                           LocalizationSettings localizationSettings                                       = null) : base(
         catalogSettings ?? new CatalogSettings(),
         commonSettings ?? new CommonSettings(),
         aclService ?? new Mock <IAclService>().Object,
         customerService ?? new Mock <ICustomerService>().Object,
         dataProvider ?? new Mock <INopDataProvider>().Object,
         dateRangeService ?? new Mock <IDateRangeService>().Object,
         eventPublisher ?? new Mock <IEventPublisher>().Object,
         languageService ?? new Mock <ILanguageService>().Object,
         localizationService ?? new Mock <ILocalizationService>().Object,
         productAttributeParser ?? new Mock <IProductAttributeParser>().Object,
         productAttributeService ?? new Mock <IProductAttributeService>().Object,
         aclRepository.FakeRepoNullPropagation(),
         crossSellProductRepository.FakeRepoNullPropagation(),
         discountProductMappingRepository.FakeRepoNullPropagation(),
         productRepository.FakeRepoNullPropagation(),
         productAttributeCombinationRepository.FakeRepoNullPropagation(),
         productAttributeMappingRepository.FakeRepoNullPropagation(),
         productCategoryRepository.FakeRepoNullPropagation(),
         productPictureRepository.FakeRepoNullPropagation(),
         productReviewRepository.FakeRepoNullPropagation(),
         productReviewHelpfulnessRepository.FakeRepoNullPropagation(),
         productWarehouseInventoryRepository.FakeRepoNullPropagation(),
         relatedProductRepository.FakeRepoNullPropagation(),
         shipmentRepository.FakeRepoNullPropagation(),
         stockQuantityHistoryRepository.FakeRepoNullPropagation(),
         storeMappingRepository.FakeRepoNullPropagation(),
         tierPriceRepository.FakeRepoNullPropagation(),
         warehouseRepository.FakeRepoNullPropagation(),
         staticCacheManager ?? new TestCacheManager(),
         storeService ?? new Mock <IStoreService>().Object,
         storeMappingService ?? new Mock <IStoreMappingService>().Object,
         workContext ?? new Mock <IWorkContext>().Object,
         localizationSettings ?? new LocalizationSettings())
 {
 }
        public new void SetUp()
        {
            _workContext = null;

            _store = new Store()
            {
                Id = 1
            };
            _storeContext = MockRepository.GenerateMock <IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            var pluginFinder = new PluginFinder();

            _shoppingCartSettings = new ShoppingCartSettings();
            _catalogSettings      = new CatalogSettings();

            //price calculation service
            _discountService         = MockRepository.GenerateMock <IDiscountService>();
            _categoryService         = MockRepository.GenerateMock <ICategoryService>();
            _productAttributeParser  = MockRepository.GenerateMock <IProductAttributeParser>();
            _productAttributeService = MockRepository.GenerateMock <IProductAttributeService>();
            _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>();
            _eventPublisher          = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _localizationService = MockRepository.GenerateMock <ILocalizationService>();
            _settingService      = MockRepository.GenerateMock <ISettingService>();
            _typeFinder          = MockRepository.GenerateMock <ITypeFinder>();

            //shipping
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");
            _shippingMethodRepository = MockRepository.GenerateMock <IRepository <ShippingMethod> >();
            _logger = new NullLogger();

            _shippingService = new ShippingService(
                _shippingMethodRepository,
                _logger,
                _productAttributeParser,
                _productService,
                _checkoutAttributeParser,
                _genericAttributeService,
                _shippingSettings,
                _eventPublisher,
                _shoppingCartSettings,
                _settingService,
                this.ProviderManager,
                _typeFinder);

            _shipmentService = MockRepository.GenerateMock <IShipmentService>();

            _paymentService          = MockRepository.GenerateMock <IPaymentService>();
            _providerManager         = MockRepository.GenerateMock <IProviderManager>();
            _checkoutAttributeParser = MockRepository.GenerateMock <ICheckoutAttributeParser>();
            _giftCardService         = MockRepository.GenerateMock <IGiftCardService>();

            //tax
            _taxSettings = new TaxSettings();
            _taxSettings.ShippingIsTaxable = true;
            _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true;
            _taxSettings.DefaultTaxAddressId = 10;

            _addressService = MockRepository.GenerateMock <IAddressService>();
            _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address()
            {
                Id = _taxSettings.DefaultTaxAddressId
            });
            _downloadService  = MockRepository.GenerateMock <IDownloadService>();
            _services         = MockRepository.GenerateMock <ICommonServices>();
            _httpRequestBase  = MockRepository.GenerateMock <HttpRequestBase>();
            _geoCountryLookup = MockRepository.GenerateMock <IGeoCountryLookup>();

            _taxService = new TaxService(_addressService, _workContext, _taxSettings, _shoppingCartSettings, pluginFinder, _geoCountryLookup, this.ProviderManager);

            _rewardPointsSettings = new RewardPointsSettings();

            _priceCalcService = new PriceCalculationService(_discountService, _categoryService, _productAttributeParser, _productService, _shoppingCartSettings, _catalogSettings,
                                                            _productAttributeService, _downloadService, _services, _httpRequestBase, _taxService);

            _orderTotalCalcService = new OrderTotalCalculationService(_workContext, _storeContext,
                                                                      _priceCalcService, _taxService, _shippingService, _providerManager,
                                                                      _checkoutAttributeParser, _discountService, _giftCardService, _genericAttributeService, _productAttributeParser,
                                                                      _taxSettings, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _catalogSettings);

            _orderService                  = MockRepository.GenerateMock <IOrderService>();
            _webHelper                     = MockRepository.GenerateMock <IWebHelper>();
            _languageService               = MockRepository.GenerateMock <ILanguageService>();
            _productService                = MockRepository.GenerateMock <IProductService>();
            _priceFormatter                = MockRepository.GenerateMock <IPriceFormatter>();
            _productAttributeFormatter     = MockRepository.GenerateMock <IProductAttributeFormatter>();
            _shoppingCartService           = MockRepository.GenerateMock <IShoppingCartService>();
            _checkoutAttributeFormatter    = MockRepository.GenerateMock <ICheckoutAttributeFormatter>();
            _customerService               = MockRepository.GenerateMock <ICustomerService>();
            _encryptionService             = MockRepository.GenerateMock <IEncryptionService>();
            _workflowMessageService        = MockRepository.GenerateMock <IWorkflowMessageService>();
            _customerActivityService       = MockRepository.GenerateMock <ICustomerActivityService>();
            _currencyService               = MockRepository.GenerateMock <ICurrencyService>();
            _affiliateService              = MockRepository.GenerateMock <IAffiliateService>();
            _newsLetterSubscriptionService = MockRepository.GenerateMock <INewsLetterSubscriptionService>();

            _paymentSettings = new PaymentSettings()
            {
                ActivePaymentMethodSystemNames = new List <string>()
                {
                    "Payments.TestMethod"
                }
            };
            _orderSettings = new OrderSettings();

            _localizationSettings = new LocalizationSettings();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _currencySettings = new CurrencySettings();

            _orderProcessingService = new OrderProcessingService(_orderService, _webHelper,
                                                                 _localizationService, _languageService,
                                                                 _productService, _paymentService, _logger,
                                                                 _orderTotalCalcService, _priceCalcService, _priceFormatter,
                                                                 _productAttributeParser, _productAttributeFormatter,
                                                                 _giftCardService, _shoppingCartService, _checkoutAttributeFormatter,
                                                                 _shippingService, _shipmentService, _taxService,
                                                                 _customerService, _discountService,
                                                                 _encryptionService, _workContext, _storeContext, _workflowMessageService,
                                                                 _customerActivityService, _currencyService, _affiliateService,
                                                                 _eventPublisher, _genericAttributeService,
                                                                 _newsLetterSubscriptionService,
                                                                 _paymentSettings, _rewardPointsSettings,
                                                                 _orderSettings, _taxSettings, _localizationSettings,
                                                                 _currencySettings, _shoppingCartSettings);
        }
Exemplo n.º 30
0
 public CustomerModelFactory(AddressSettings addressSettings,
                             CaptchaSettings captchaSettings,
                             CatalogSettings catalogSettings,
                             CommonSettings commonSettings,
                             CustomerSettings customerSettings,
                             DateTimeSettings dateTimeSettings,
                             ExternalAuthenticationSettings externalAuthenticationSettings,
                             ForumSettings forumSettings,
                             GdprSettings gdprSettings,
                             IAddressModelFactory addressModelFactory,
                             IAuthenticationPluginManager authenticationPluginManager,
                             ICountryService countryService,
                             ICustomerAttributeParser customerAttributeParser,
                             ICustomerAttributeService customerAttributeService,
                             IDateTimeHelper dateTimeHelper,
                             IDownloadService downloadService,
                             IGdprService gdprService,
                             IGenericAttributeService genericAttributeService,
                             ILocalizationService localizationService,
                             INewsLetterSubscriptionService newsLetterSubscriptionService,
                             IOrderService orderService,
                             IPictureService pictureService,
                             IReturnRequestService returnRequestService,
                             IStateProvinceService stateProvinceService,
                             IStoreContext storeContext,
                             IStoreMappingService storeMappingService,
                             IUrlRecordService urlRecordService,
                             IWorkContext workContext,
                             MediaSettings mediaSettings,
                             OrderSettings orderSettings,
                             RewardPointsSettings rewardPointsSettings,
                             SecuritySettings securitySettings,
                             TaxSettings taxSettings,
                             VendorSettings vendorSettings)
 {
     _addressSettings  = addressSettings;
     _captchaSettings  = captchaSettings;
     _catalogSettings  = catalogSettings;
     _commonSettings   = commonSettings;
     _customerSettings = customerSettings;
     _dateTimeSettings = dateTimeSettings;
     _externalAuthenticationSettings = externalAuthenticationSettings;
     _forumSettings               = forumSettings;
     _gdprSettings                = gdprSettings;
     _addressModelFactory         = addressModelFactory;
     _authenticationPluginManager = authenticationPluginManager;
     _countryService              = countryService;
     _customerAttributeParser     = customerAttributeParser;
     _customerAttributeService    = customerAttributeService;
     _dateTimeHelper              = dateTimeHelper;
     _downloadService             = downloadService;
     _gdprService                   = gdprService;
     _genericAttributeService       = genericAttributeService;
     _localizationService           = localizationService;
     _newsLetterSubscriptionService = newsLetterSubscriptionService;
     _orderService                  = orderService;
     _pictureService                = pictureService;
     _returnRequestService          = returnRequestService;
     _stateProvinceService          = stateProvinceService;
     _storeContext                  = storeContext;
     _storeMappingService           = storeMappingService;
     _urlRecordService              = urlRecordService;
     _workContext                   = workContext;
     _mediaSettings                 = mediaSettings;
     _orderSettings                 = orderSettings;
     _rewardPointsSettings          = rewardPointsSettings;
     _securitySettings              = securitySettings;
     _taxSettings                   = taxSettings;
     _vendorSettings                = vendorSettings;
 }
        public void TestInitialize()
        {
            new Grand.Services.Tests.ServiceTest().PluginInitializator();

            _workContext = new Mock <IWorkContext>().Object;

            _store = new Store {
                Id = "1"
            };
            var tempStoreContext = new Mock <IStoreContext>();

            {
                tempStoreContext.Setup(x => x.CurrentStore).Returns(_store);
                _storeContext = tempStoreContext.Object;
            }

            _productService = new Mock <IProductService>().Object;

            var pluginFinder = new PluginFinder();
            var cacheManager = new TestMemoryCacheManager(new Mock <IMemoryCache>().Object);

            _discountService        = new Mock <IDiscountService>().Object;
            _categoryService        = new Mock <ICategoryService>().Object;
            _manufacturerService    = new Mock <IManufacturerService>().Object;
            _productAttributeParser = new Mock <IProductAttributeParser>().Object;
            _vendorService          = new Mock <IVendorService>().Object;
            _storeService           = new Mock <IStoreService>().Object;
            _currencyService        = new Mock <ICurrencyService>().Object;

            _shoppingCartSettings = new ShoppingCartSettings();
            _catalogSettings      = new CatalogSettings();
            _currencySettings     = new CurrencySettings();
            _customerService      = new Mock <ICustomerService>().Object;

            _priceCalcService = new PriceCalculationService(_workContext, _storeContext,
                                                            _discountService, _categoryService,
                                                            _manufacturerService, _productAttributeParser, _productService, _customerService,
                                                            cacheManager, _vendorService, _storeService, _currencyService,
                                                            _shoppingCartSettings, _catalogSettings);

            var tempEventPublisher = new Mock <IEventPublisher>();

            {
                tempEventPublisher.Setup(x => x.Publish(It.IsAny <object>()));
                _eventPublisher = tempEventPublisher.Object;
            }

            _localizationService = new Mock <ILocalizationService>().Object;

            //shipping
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");
            _shippingMethodRepository = new Mock <IRepository <ShippingMethod> >().Object;
            _deliveryDateRepository   = new Mock <IRepository <DeliveryDate> >().Object;
            _warehouseRepository      = new Mock <IRepository <Warehouse> >().Object;
            _pickupPointRepository    = new Mock <IRepository <PickupPoint> >().Object;

            _logger          = new NullLogger();
            _shippingService = new ShippingService(_shippingMethodRepository,
                                                   _deliveryDateRepository,
                                                   _warehouseRepository,
                                                   _pickupPointRepository,
                                                   _logger,
                                                   _productService,
                                                   _productAttributeParser,
                                                   _checkoutAttributeParser,
                                                   _genericAttributeService,
                                                   _localizationService,
                                                   _addressService,
                                                   _shippingSettings,
                                                   pluginFinder,
                                                   _storeContext,
                                                   _eventPublisher,
                                                   _shoppingCartSettings,
                                                   cacheManager,
                                                   null);


            _paymentService          = new Mock <IPaymentService>().Object;
            _checkoutAttributeParser = new Mock <ICheckoutAttributeParser>().Object;
            _giftCardService         = new Mock <IGiftCardService>().Object;
            _genericAttributeService = new Mock <IGenericAttributeService>().Object;

            _geoLookupService = new Mock <IGeoLookupService>().Object;
            _countryService   = new Mock <ICountryService>().Object;
            _customerSettings = new CustomerSettings();
            _addressSettings  = new AddressSettings();

            //tax
            _taxSettings = new TaxSettings();
            _taxSettings.ShippingIsTaxable = true;
            _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true;
            _taxSettings.DefaultTaxAddressId = "10";

            var tempAddressService = new Mock <IAddressService>();

            {
                tempAddressService.Setup(x => x.GetAddressByIdSettings(_taxSettings.DefaultTaxAddressId))
                .Returns(new Address {
                    Id = _taxSettings.DefaultTaxAddressId
                });
                _addressService = tempAddressService.Object;
            }

            _taxService = new TaxService(_addressService, _workContext, _taxSettings,
                                         pluginFinder, _geoLookupService, _countryService, _logger, _customerSettings, _addressSettings);

            _rewardPointsSettings = new RewardPointsSettings();

            _orderTotalCalcService = new OrderTotalCalculationService(_workContext, _storeContext,
                                                                      _priceCalcService, _taxService, _shippingService, _paymentService,
                                                                      _checkoutAttributeParser, _discountService, _giftCardService, _genericAttributeService,
                                                                      null, _productService, _currencyService, _taxSettings, _rewardPointsSettings,
                                                                      _shippingSettings, _shoppingCartSettings, _catalogSettings);
        }
        public virtual IActionResult SearchTermAutoComplete(string term, string categoryId, [FromServices] CatalogSettings catalogSettings)
        {
            if (String.IsNullOrWhiteSpace(term) || term.Length < catalogSettings.ProductSearchTermMinimumLength)
            {
                return(Content(""));
            }

            var result = _catalogViewModelService.PrepareSearchAutoComplete(term, categoryId);

            return(Json(result));
        }
Exemplo n.º 33
0
 public static CatalogSettingsModel ToModel(this CatalogSettings entity)
 {
     return(Mapper.Map <CatalogSettings, CatalogSettingsModel>(entity));
 }
        public new void SetUp()
        {
            _workContext = null;

            var pluginFinder = new PluginFinder(new AppDomainTypeFinder());
            var cacheManager = new NopNullCache();

            _shoppingCartSettings = new ShoppingCartSettings();
            _catalogSettings      = new CatalogSettings();

            //price calculation service
            _discountService        = MockRepository.GenerateMock <IDiscountService>();
            _categoryService        = MockRepository.GenerateMock <ICategoryService>();
            _productAttributeParser = MockRepository.GenerateMock <IProductAttributeParser>();
            _priceCalcService       = new PriceCalculationService(_workContext, _discountService,
                                                                  _categoryService, _productAttributeParser, _shoppingCartSettings, _catalogSettings);

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            //shipping
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");
            _shippingMethodRepository = MockRepository.GenerateMock <IRepository <ShippingMethod> >();
            _logger          = new NullLogger();
            _shippingService = new ShippingService(cacheManager,
                                                   _shippingMethodRepository,
                                                   _logger,
                                                   _productAttributeParser,
                                                   _checkoutAttributeParser,
                                                   _shippingSettings, pluginFinder, _eventPublisher);


            _paymentService          = MockRepository.GenerateMock <IPaymentService>();
            _checkoutAttributeParser = MockRepository.GenerateMock <ICheckoutAttributeParser>();
            _giftCardService         = MockRepository.GenerateMock <IGiftCardService>();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            //tax
            _taxSettings = new TaxSettings();
            _taxSettings.ShippingIsTaxable = true;
            _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true;
            _taxSettings.DefaultTaxAddressId = 10;
            _addressService = MockRepository.GenerateMock <IAddressService>();
            _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address()
            {
                Id = _taxSettings.DefaultTaxAddressId
            });
            _taxService = new TaxService(_addressService, _workContext, _taxSettings, pluginFinder, _eventPublisher);

            _rewardPointsSettings = new RewardPointsSettings();

            _orderTotalCalcService = new OrderTotalCalculationService(_workContext,
                                                                      _priceCalcService, _taxService, _shippingService, _paymentService,
                                                                      _checkoutAttributeParser, _discountService, _giftCardService,
                                                                      _taxSettings, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _catalogSettings);

            _orderService               = MockRepository.GenerateMock <IOrderService>();
            _webHelper                  = MockRepository.GenerateMock <IWebHelper>();
            _localizationService        = MockRepository.GenerateMock <ILocalizationService>();
            _languageService            = MockRepository.GenerateMock <ILanguageService>();
            _productService             = MockRepository.GenerateMock <IProductService>();
            _priceFormatter             = MockRepository.GenerateMock <IPriceFormatter>();
            _productAttributeFormatter  = MockRepository.GenerateMock <IProductAttributeFormatter>();
            _shoppingCartService        = MockRepository.GenerateMock <IShoppingCartService>();
            _checkoutAttributeFormatter = MockRepository.GenerateMock <ICheckoutAttributeFormatter>();
            _customerService            = MockRepository.GenerateMock <ICustomerService>();
            _encryptionService          = MockRepository.GenerateMock <IEncryptionService>();
            _workflowMessageService     = MockRepository.GenerateMock <IWorkflowMessageService>();
            _smsService                 = MockRepository.GenerateMock <ISmsService>();
            _customerActivityService    = MockRepository.GenerateMock <ICustomerActivityService>();
            _currencyService            = MockRepository.GenerateMock <ICurrencyService>();

            _paymentSettings = new PaymentSettings()
            {
                ActivePaymentMethodSystemNames = new List <string>()
                {
                    "Payments.TestMethod"
                }
            };
            _orderSettings = new OrderSettings();

            _localizationSettings = new LocalizationSettings();

            _orderProcessingService = new OrderProcessingService(_orderService, _webHelper,
                                                                 _localizationService, _languageService,
                                                                 _productService, _paymentService, _logger,
                                                                 _orderTotalCalcService, _priceCalcService, _priceFormatter,
                                                                 _productAttributeParser, _productAttributeFormatter,
                                                                 _giftCardService, _shoppingCartService, _checkoutAttributeFormatter,
                                                                 _shippingService, _taxService,
                                                                 _customerService, _discountService,
                                                                 _encryptionService, _workContext, _workflowMessageService,
                                                                 _smsService, _customerActivityService, _currencyService,
                                                                 _paymentSettings, _rewardPointsSettings,
                                                                 _orderSettings, _taxSettings, _localizationSettings);
        }
 public CustomerModelFactory(IAddressModelFactory addressModelFactory,
                             IDateTimeHelper dateTimeHelper,
                             DateTimeSettings dateTimeSettings,
                             TaxSettings taxSettings,
                             ILocalizationService localizationService,
                             IWorkContext workContext,
                             IStoreContext storeContext,
                             IStoreMappingService storeMappingService,
                             ICustomerAttributeParser customerAttributeParser,
                             ICustomerAttributeService customerAttributeService,
                             IGenericAttributeService genericAttributeService,
                             RewardPointsSettings rewardPointsSettings,
                             CustomerSettings customerSettings,
                             AddressSettings addressSettings,
                             ForumSettings forumSettings,
                             OrderSettings orderSettings,
                             ICountryService countryService,
                             IStateProvinceService stateProvinceService,
                             IOrderService orderService,
                             IPictureService pictureService,
                             INewsLetterSubscriptionService newsLetterSubscriptionService,
                             IOpenAuthenticationService openAuthenticationService,
                             IDownloadService downloadService,
                             IReturnRequestService returnRequestService,
                             MediaSettings mediaSettings,
                             CaptchaSettings captchaSettings,
                             SecuritySettings securitySettings,
                             ExternalAuthenticationSettings externalAuthenticationSettings,
                             CatalogSettings catalogSettings,
                             VendorSettings vendorSettings)
 {
     this._addressModelFactory            = addressModelFactory;
     this._dateTimeHelper                 = dateTimeHelper;
     this._dateTimeSettings               = dateTimeSettings;
     this._taxSettings                    = taxSettings;
     this._localizationService            = localizationService;
     this._workContext                    = workContext;
     this._storeContext                   = storeContext;
     this._storeMappingService            = storeMappingService;
     this._customerAttributeParser        = customerAttributeParser;
     this._customerAttributeService       = customerAttributeService;
     this._genericAttributeService        = genericAttributeService;
     this._rewardPointsSettings           = rewardPointsSettings;
     this._customerSettings               = customerSettings;
     this._addressSettings                = addressSettings;
     this._forumSettings                  = forumSettings;
     this._orderSettings                  = orderSettings;
     this._countryService                 = countryService;
     this._stateProvinceService           = stateProvinceService;
     this._orderService                   = orderService;
     this._pictureService                 = pictureService;
     this._newsLetterSubscriptionService  = newsLetterSubscriptionService;
     this._openAuthenticationService      = openAuthenticationService;
     this._downloadService                = downloadService;
     this._returnRequestService           = returnRequestService;
     this._mediaSettings                  = mediaSettings;
     this._captchaSettings                = captchaSettings;
     this._securitySettings               = securitySettings;
     this._externalAuthenticationSettings = externalAuthenticationSettings;
     this._catalogSettings                = catalogSettings;
     this._vendorSettings                 = vendorSettings;
 }
Exemplo n.º 36
0
        public new void SetUp()
        {
            _productService = new Mock <IProductService>();

            _discountService          = new Mock <IDiscountService>();
            _categoryService          = new Mock <ICategoryService>();
            _manufacturerService      = new Mock <IManufacturerService>();
            _productAttributeParser   = new Mock <IProductAttributeParser>();
            _eventPublisher           = new Mock <IEventPublisher>();
            _localizationService      = new Mock <ILocalizationService>();
            _shippingMethodRepository = new Mock <IRepository <ShippingMethod> >();
            _warehouseRepository      = new Mock <IRepository <Warehouse> >();
            _shipmentService          = new Mock <IShipmentService>();
            _paymentService           = new Mock <IPaymentService>();
            _checkoutAttributeParser  = new Mock <ICheckoutAttributeParser>();
            _giftCardService          = new Mock <IGiftCardService>();
            _genericAttributeService  = new Mock <IGenericAttributeService>();
            _geoLookupService         = new Mock <IGeoLookupService>();
            _countryService           = new Mock <ICountryService>();
            _stateProvinceService     = new Mock <IStateProvinceService>();
            _eventPublisher           = new Mock <IEventPublisher>();
            _addressService           = new Mock <IAddressService>();
            _rewardPointService       = new Mock <IRewardPointService>();
            _webHelper                  = new Mock <IWebHelper>();
            _languageService            = new Mock <ILanguageService>();
            _priceFormatter             = new Mock <IPriceFormatter>();
            _productAttributeFormatter  = new Mock <IProductAttributeFormatter>();
            _shoppingCartService        = new Mock <IShoppingCartService>();
            _checkoutAttributeFormatter = new Mock <ICheckoutAttributeFormatter>();
            _customerService            = new Mock <ICustomerService>();
            _encryptionService          = new Mock <IEncryptionService>();
            _workflowMessageService     = new Mock <IWorkflowMessageService>();
            _customerActivityService    = new Mock <ICustomerActivityService>();
            _currencyService            = new Mock <ICurrencyService>();
            _affiliateService           = new Mock <IAffiliateService>();
            _vendorService              = new Mock <IVendorService>();
            _pdfService                 = new Mock <IPdfService>();
            _customNumberFormatter      = new Mock <ICustomNumberFormatter>();
            _rewardPointService         = new Mock <IRewardPointService>();


            _workContext = null;

            //setup

            _storeContext = new Mock <IStoreContext>();
            _store        = new Store {
                Id = 1
            };
            _storeContext.Setup(x => x.CurrentStore).Returns(_store);

            _catalogSettings = new CatalogSettings();
            var cacheManager = new TestCacheManager();

            _currencySettings = new CurrencySettings();

            //price calculation service
            _priceCalcService = new PriceCalculationService(_catalogSettings, _currencySettings, _categoryService.Object,
                                                            _currencyService.Object, _customerService.Object, _discountService.Object, _manufacturerService.Object, _productAttributeParser.Object,
                                                            _productService.Object, cacheManager, _storeContext.Object, _workContext);

            _eventPublisher.Setup(x => x.Publish(It.IsAny <object>()));

            var pluginService = new FakePluginService(_catalogSettings);

            _paymentPluginManager  = new PaymentPluginManager(pluginService, null, _paymentSettings);
            _pickupPluginManager   = new PickupPluginManager(pluginService, _shippingSettings);
            _shippingPluginManager = new ShippingPluginManager(pluginService, _shippingSettings);
            _taxPluginManager      = new TaxPluginManager(pluginService, _taxSettings);

            _shoppingCartSettings = new ShoppingCartSettings();
            //shipping
            _shippingSettings = new ShippingSettings
            {
                ActiveShippingRateComputationMethodSystemNames = new List <string>()
            };
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");

            _logger           = new NullLogger();
            _customerSettings = new CustomerSettings();
            _addressSettings  = new AddressSettings();

            var shippingMethodCountryMappingRepository = new Mock <IRepository <ShippingMethodCountryMapping> >();

            _shippingService = new ShippingService(_addressService.Object,
                                                   _checkoutAttributeParser.Object,
                                                   _countryService.Object,
                                                   _customerService.Object,
                                                   _eventPublisher.Object,
                                                   _genericAttributeService.Object,
                                                   _localizationService.Object,
                                                   _logger,
                                                   _pickupPluginManager,
                                                   _priceCalcService,
                                                   _productAttributeParser.Object,
                                                   _productService.Object,
                                                   _shippingMethodRepository.Object,
                                                   shippingMethodCountryMappingRepository.Object,
                                                   _warehouseRepository.Object,
                                                   _shippingPluginManager,
                                                   _stateProvinceService.Object,
                                                   _storeContext.Object,
                                                   _shippingSettings,
                                                   _shoppingCartSettings);

            //tax
            _taxSettings = new TaxSettings
            {
                ShippingIsTaxable = true,
                PaymentMethodAdditionalFeeIsTaxable = true,
                DefaultTaxAddressId = 10
            };

            _addressService.Setup(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Returns(new Address {
                Id = _taxSettings.DefaultTaxAddressId
            });

            _taxService = new TaxService(_addressSettings,
                                         _customerSettings,
                                         _addressService.Object,
                                         _countryService.Object,
                                         _customerService.Object,
                                         _genericAttributeService.Object,
                                         _geoLookupService.Object,
                                         _logger,
                                         _stateProvinceService.Object,
                                         _storeContext.Object,
                                         _taxPluginManager,
                                         _webHelper.Object,
                                         _workContext,
                                         _shippingSettings,
                                         _taxSettings);

            _rewardPointsSettings = new RewardPointsSettings();

            _recurringPaymentRepository = new Mock <IRepository <RecurringPayment> >();
            var recurringPayments = new List <RecurringPayment>();

            _recurringPaymentRepository.Setup(r => r.Insert(It.IsAny <RecurringPayment>())).Callback((RecurringPayment rph) => recurringPayments.Add(rph));
            _recurringPaymentRepository.Setup(r => r.Table).Returns(recurringPayments.AsQueryable());

            _recurringPaymentHistoryRepository = new Mock <IRepository <RecurringPaymentHistory> >();
            var recurringPaymentHistory = new List <RecurringPaymentHistory>();

            _recurringPaymentHistoryRepository.Setup(r => r.Insert(It.IsAny <RecurringPaymentHistory>())).Callback((RecurringPaymentHistory rph) => recurringPaymentHistory.Add(rph));
            _recurringPaymentHistoryRepository.Setup(r => r.Table).Returns(recurringPaymentHistory.AsQueryable());

            _orderService = new OrderService(_eventPublisher.Object, null, null, null, null, null, null, null, null, _recurringPaymentRepository.Object, _recurringPaymentHistoryRepository.Object, _shipmentService.Object);


            _orderTotalCalcService = new OrderTotalCalculationService(_catalogSettings,
                                                                      _addressService.Object,
                                                                      _checkoutAttributeParser.Object,
                                                                      _customerService.Object,
                                                                      _discountService.Object,
                                                                      _genericAttributeService.Object,
                                                                      _giftCardService.Object,
                                                                      _orderService,
                                                                      _paymentService.Object,
                                                                      _priceCalcService,
                                                                      _productService.Object,
                                                                      _rewardPointService.Object,
                                                                      _shippingPluginManager,
                                                                      _shippingService,
                                                                      _shoppingCartService.Object,
                                                                      _storeContext.Object,
                                                                      _taxService,
                                                                      _workContext,
                                                                      _rewardPointsSettings,
                                                                      _shippingSettings,
                                                                      _shoppingCartSettings,
                                                                      _taxSettings);

            _paymentSettings = new PaymentSettings
            {
                ActivePaymentMethodSystemNames = new List <string>
                {
                    "Payments.TestMethod"
                }
            };
            _orderSettings = new OrderSettings();

            _localizationSettings = new LocalizationSettings();

            _eventPublisher.Setup(x => x.Publish(It.IsAny <object>()));

            _orderProcessingService = new OrderProcessingService(_currencySettings,
                                                                 _addressService.Object,
                                                                 _affiliateService.Object,
                                                                 _checkoutAttributeFormatter.Object,
                                                                 _countryService.Object,
                                                                 _currencyService.Object,
                                                                 _customerActivityService.Object,
                                                                 _customerService.Object,
                                                                 _customNumberFormatter.Object,
                                                                 _discountService.Object,
                                                                 _encryptionService.Object,
                                                                 _eventPublisher.Object,
                                                                 _genericAttributeService.Object,
                                                                 _giftCardService.Object,
                                                                 _languageService.Object,
                                                                 _localizationService.Object,
                                                                 _logger,
                                                                 _orderService,
                                                                 _orderTotalCalcService,
                                                                 _paymentPluginManager,
                                                                 _paymentService.Object,
                                                                 _pdfService.Object,
                                                                 _priceCalcService,
                                                                 _priceFormatter.Object,
                                                                 _productAttributeFormatter.Object,
                                                                 _productAttributeParser.Object,
                                                                 _productService.Object,
                                                                 _rewardPointService.Object,
                                                                 _shipmentService.Object,
                                                                 _shippingPluginManager,
                                                                 _shippingService,
                                                                 _shoppingCartService.Object,
                                                                 _stateProvinceService.Object,
                                                                 _storeContext.Object,
                                                                 _taxService,
                                                                 _vendorService.Object,
                                                                 _webHelper.Object,
                                                                 _workContext,
                                                                 _workflowMessageService.Object,
                                                                 _localizationSettings,
                                                                 _orderSettings,
                                                                 _paymentSettings,
                                                                 _rewardPointsSettings,
                                                                 _shippingSettings,
                                                                 _taxSettings);
        }
Exemplo n.º 37
0
        public void UpdateKeywordsAndOntology(CatalogSettings catalogSettings = null)
        {
            var desc = KeywordsServicesFactory.GetKeywordsList(catalogSettings ?? _parent.CatalogSettings).GetOntologyDesc();

            // Select root of OntoloyTree
            if (_selectedKeywords == null &&
                desc.OntoloyTree.Nodes.Count > 0)
            {
                _selectedKeywords = new[] { desc.OntoloyTree.Nodes[0].title };
            }

            _ontologyDesc = desc;
            RaiseKeywordsChanged();
        }
Exemplo n.º 38
0
 public UriComposer(CatalogSettings catalogSettings) => _catalogSettings = catalogSettings;