예제 #1
0
 public ShoppingCartValidator(
     IWorkContext workContext,
     ICurrencyService currencyService,
     IProductService productService,
     ITranslationService translationService,
     IProductAttributeParser productAttributeParser,
     ICheckoutAttributeService checkoutAttributeService,
     ICheckoutAttributeParser checkoutAttributeParser,
     IPriceFormatter priceFormatter,
     IMediator mediator,
     IPermissionService permissionService,
     IAclService aclService,
     IProductAttributeService productAttributeService,
     IProductReservationService productReservationService,
     IStockQuantityService stockQuantityService,
     IWarehouseService warehouseService,
     ShoppingCartSettings shoppingCartSettings)
 {
     _workContext              = workContext;
     _currencyService          = currencyService;
     _productService           = productService;
     _translationService       = translationService;
     _productAttributeParser   = productAttributeParser;
     _checkoutAttributeService = checkoutAttributeService;
     _checkoutAttributeParser  = checkoutAttributeParser;
     _priceFormatter           = priceFormatter;
     _mediator                  = mediator;
     _permissionService         = permissionService;
     _aclService                = aclService;
     _productAttributeService   = productAttributeService;
     _productReservationService = productReservationService;
     _stockQuantityService      = stockQuantityService;
     _warehouseService          = warehouseService;
     _shoppingCartSettings      = shoppingCartSettings;
 }
예제 #2
0
 public ProductController(
     IProductService productService,
     IProductWebService productWebService,
     IProductReservationService productReservationService,
     IWorkContext workContext,
     IStoreContext storeContext,
     ILocalizationService localizationService,
     IWebHelper webHelper,
     IRecentlyViewedProductsService recentlyViewedProductsService,
     ICompareProductsService compareProductsService,
     IOrderReportService orderReportService,
     IAclService aclService,
     IStoreMappingService storeMappingService,
     IPermissionService permissionService,
     ICustomerActivityService customerActivityService,
     ICustomerActionEventService customerActionEventService,
     IEventPublisher eventPublisher,
     CatalogSettings catalogSettings,
     ShoppingCartSettings shoppingCartSettings,
     LocalizationSettings localizationSettings,
     CaptchaSettings captchaSettings,
     ICacheManager cacheManager,
     IOrderService orderService
     )
 {
     this._productService            = productService;
     this._productWebService         = productWebService;
     this._productReservationService = productReservationService;
     this._workContext                   = workContext;
     this._storeContext                  = storeContext;
     this._localizationService           = localizationService;
     this._webHelper                     = webHelper;
     this._recentlyViewedProductsService = recentlyViewedProductsService;
     this._compareProductsService        = compareProductsService;
     this._orderReportService            = orderReportService;
     this._aclService                    = aclService;
     this._storeMappingService           = storeMappingService;
     this._permissionService             = permissionService;
     this._customerActivityService       = customerActivityService;
     this._customerActionEventService    = customerActionEventService;
     this._eventPublisher                = eventPublisher;
     this._catalogSettings               = catalogSettings;
     this._shoppingCartSettings          = shoppingCartSettings;
     this._localizationSettings          = localizationSettings;
     this._captchaSettings               = captchaSettings;
     this._cacheManager                  = cacheManager;
     this._orderService                  = orderService;
 }
예제 #3
0
 public CancelOrderCommandHandler(
     IMediator mediator,
     IOrderService orderService,
     IShipmentService shipmentService,
     IProductService productService,
     IProductReservationService productReservationService,
     IAuctionService auctionService,
     IDiscountService discountService)
 {
     _mediator                  = mediator;
     _orderService              = orderService;
     _shipmentService           = shipmentService;
     _productService            = productService;
     _productReservationService = productReservationService;
     _auctionService            = auctionService;
     _discountService           = discountService;
 }
예제 #4
0
 public DeleteOrderCommandHandler(
     IMediator mediator,
     IOrderService orderService,
     IShipmentService shipmentService,
     IProductService productService,
     IProductReservationService productReservationService,
     IAuctionService auctionService,
     IDiscountService discountService,
     OrderSettings orderSettings)
 {
     _mediator                  = mediator;
     _orderService              = orderService;
     _shipmentService           = shipmentService;
     _productService            = productService;
     _productReservationService = productReservationService;
     _auctionService            = auctionService;
     _discountService           = discountService;
     _orderSettings             = orderSettings;
 }
        public void TestInitialize()
        {
            _productReservationRepository         = new MongoDBRepositoryTest <ProductReservation>();
            _productRepository                    = new MongoDBRepositoryTest <Product>();
            _customerReservationsHelperRepository = new MongoDBRepositoryTest <CustomerReservationsHelper>();
            _workContext = new Mock <IWorkContext>().Object;

            var eventPublisher = new Mock <IEventPublisher>();

            eventPublisher.Setup(x => x.Publish(new object()));
            _eventPublisher = eventPublisher.Object;

            _productReservationService = new ProductReservationService(_productReservationRepository,
                                                                       _customerReservationsHelperRepository, _eventPublisher, _workContext);

            _productRepository.Insert(new Product
            {
                ProductType = ProductType.Reservation,
                Name        = "Temp"
            });
        }
예제 #6
0
 public AddToCartController(IProductService productService,
                            IProductReservationService productReservationService,
                            IShoppingCartService shoppingCartService,
                            IShoppingCartViewModelService shoppingCartViewModelService,
                            IWorkContext workContext,
                            IStoreContext storeContext,
                            ILocalizationService localizationService,
                            IWebHelper webHelper,
                            ICurrencyService currencyService,
                            IPermissionService permissionService,
                            ICustomerActivityService customerActivityService,
                            ICacheManager cacheManager,
                            ITaxService taxService,
                            IProductAttributeParser productAttributeParser,
                            IPriceCalculationService priceCalculationService,
                            IPriceFormatter priceFormatter,
                            IPictureService pictureService,
                            ShoppingCartSettings shoppingCartSettings,
                            MediaSettings mediaSettings)
 {
     this._productService               = productService;
     this._productReservationService    = productReservationService;
     this._shoppingCartService          = shoppingCartService;
     this._shoppingCartViewModelService = shoppingCartViewModelService;
     this._workContext             = workContext;
     this._storeContext            = storeContext;
     this._localizationService     = localizationService;
     this._webHelper               = webHelper;
     this._currencyService         = currencyService;
     this._permissionService       = permissionService;
     this._customerActivityService = customerActivityService;
     this._cacheManager            = cacheManager;
     this._taxService              = taxService;
     this._productAttributeParser  = productAttributeParser;
     this._priceCalculationService = priceCalculationService;
     this._priceFormatter          = priceFormatter;
     this._pictureService          = pictureService;
     this._mediaSettings           = mediaSettings;
     this._shoppingCartSettings    = shoppingCartSettings;
 }
 public AddToCartController(IProductService productService,
                            IProductReservationService productReservationService,
                            IShoppingCartService shoppingCartService,
                            IShoppingCartViewModelService shoppingCartViewModelService,
                            IWorkContext workContext,
                            IStoreContext storeContext,
                            ILocalizationService localizationService,
                            ICurrencyService currencyService,
                            ICustomerActivityService customerActivityService,
                            ShoppingCartSettings shoppingCartSettings)
 {
     _productService               = productService;
     _productReservationService    = productReservationService;
     _shoppingCartService          = shoppingCartService;
     _shoppingCartViewModelService = shoppingCartViewModelService;
     _workContext             = workContext;
     _storeContext            = storeContext;
     _localizationService     = localizationService;
     _currencyService         = currencyService;
     _customerActivityService = customerActivityService;
     _shoppingCartSettings    = shoppingCartSettings;
 }
 public CancelOrderCommandHandler(
     IMediator mediator,
     IOrderService orderService,
     IShipmentService shipmentService,
     IProductService productService,
     IInventoryManageService inventoryManageService,
     IProductReservationService productReservationService,
     IAuctionService auctionService,
     IDiscountService discountService,
     IPaymentService paymentService,
     IPaymentTransactionService paymentTransactionService)
 {
     _mediator                  = mediator;
     _orderService              = orderService;
     _shipmentService           = shipmentService;
     _productService            = productService;
     _inventoryManageService    = inventoryManageService;
     _productReservationService = productReservationService;
     _auctionService            = auctionService;
     _discountService           = discountService;
     _paymentService            = paymentService;
     _paymentTransactionService = paymentTransactionService;
 }
예제 #9
0
 public ShoppingCartService(
     IWorkContext workContext,
     IProductService productService,
     IProductAttributeParser productAttributeParser,
     ICheckoutAttributeParser checkoutAttributeParser,
     ICustomerService customerService,
     IMediator mediator,
     IUserFieldService userFieldService,
     IProductReservationService productReservationService,
     IShoppingCartValidator shoppingCartValidator,
     ShoppingCartSettings shoppingCartSettings)
 {
     _workContext             = workContext;
     _productService          = productService;
     _productAttributeParser  = productAttributeParser;
     _checkoutAttributeParser = checkoutAttributeParser;
     _customerService         = customerService;
     _mediator                  = mediator;
     _userFieldService          = userFieldService;
     _productReservationService = productReservationService;
     _shoppingCartValidator     = shoppingCartValidator;
     _shoppingCartSettings      = shoppingCartSettings;
 }
예제 #10
0
        public virtual async Task <IActionResult> GetDatesForMonth(string productId, int month, string parameter, int year, [FromServices] IProductReservationService productReservationService)
        {
            var allReservations = await productReservationService.GetProductReservationsByProductId(productId, true, null);

            var query = allReservations.Where(x => x.Date.Month == month && x.Date.Year == year && x.Date >= DateTime.UtcNow);

            if (!string.IsNullOrEmpty(parameter))
            {
                query = query.Where(x => x.Parameter == parameter);
            }

            var reservations = query.ToList();
            var inCart       = _shoppingCartService.GetShoppingCart(_storeContext.CurrentStore.Id)
                               .Where(x => !string.IsNullOrEmpty(x.ReservationId)).ToList();

            foreach (var cartItem in inCart)
            {
                var match = reservations.FirstOrDefault(x => x.Id == cartItem.ReservationId);
                if (match != null)
                {
                    reservations.Remove(match);
                }
            }

            var toReturn = reservations.GroupBy(x => x.Date).Select(x => x.First()).ToList();

            return(Json(toReturn));
        }
        public void TestInitialize()
        {
            _workContext = null;

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

            var pluginFinder = new PluginFinder();

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

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

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

            //price calculation service
            _discountService           = new Mock <IDiscountService>().Object;
            _categoryService           = new Mock <ICategoryService>().Object;
            _manufacturerService       = new Mock <IManufacturerService>().Object;
            _storeService              = new Mock <IStoreService>().Object;
            _customerService           = new Mock <ICustomerService>().Object;
            _productReservationService = new Mock <IProductReservationService>().Object;
            _currencyService           = new Mock <ICurrencyService>().Object;
            _auctionService            = new Mock <IAuctionService>().Object;

            _productAttributeParser = new Mock <IProductAttributeParser>().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);
            _shipmentService = new Mock <IShipmentService>().Object;


            tempPaymentService = new Mock <IPaymentService>();
            {
                _paymentService = tempPaymentService.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
            {
                ShippingIsTaxable = true,
                PaymentMethodAdditionalFeeIsTaxable = true,
                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);

            _orderService               = new Mock <IOrderService>().Object;
            _webHelper                  = new Mock <IWebHelper>().Object;
            _languageService            = new Mock <ILanguageService>().Object;
            _priceFormatter             = new Mock <IPriceFormatter>().Object;
            _productAttributeFormatter  = new Mock <IProductAttributeFormatter>().Object;
            _shoppingCartService        = new Mock <IShoppingCartService>().Object;
            _checkoutAttributeFormatter = new Mock <ICheckoutAttributeFormatter>().Object;
            _encryptionService          = new Mock <IEncryptionService>().Object;
            _workflowMessageService     = new Mock <IWorkflowMessageService>().Object;
            _customerActivityService    = new Mock <ICustomerActivityService>().Object;
            _currencyService            = new Mock <ICurrencyService>().Object;
            _affiliateService           = new Mock <IAffiliateService>().Object;
            _vendorService              = new Mock <IVendorService>().Object;
            _pdfService                 = new Mock <IPdfService>().Object;

            _paymentSettings = new PaymentSettings
            {
                ActivePaymentMethodSystemNames = new List <string>
                {
                    "Payments.TestMethod"
                }
            };
            _orderSettings        = new OrderSettings();
            _localizationSettings = new LocalizationSettings();
            ICustomerActionEventService tempICustomerActionEventService = new Mock <ICustomerActionEventService>().Object;

            _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,
                                                                 _workflowMessageService, _vendorService,
                                                                 _customerActivityService, tempICustomerActionEventService,
                                                                 _currencyService, _affiliateService,
                                                                 _eventPublisher, _pdfService, null, null, _storeContext, _productReservationService, _auctionService,
                                                                 _shippingSettings, _paymentSettings, _rewardPointsSettings,
                                                                 _orderSettings, _taxSettings, _localizationSettings);
        }
예제 #12
0
        public IActionResult GetDatesForMonth(string productId, int month, string parameter, int year, [FromServices] IProductReservationService productReservationService)
        {
            var allReservations = productReservationService.GetProductReservationsByProductId(productId, true, null);
            var query           = allReservations.Where(x => x.Date.Month == month && x.Date.Year == year && x.Date >= DateTime.UtcNow);

            if (!string.IsNullOrEmpty(parameter))
            {
                query = query.Where(x => x.Parameter == parameter);
            }

            var reservations = query.ToList();
            var inCart       = _workContext.CurrentCustomer.ShoppingCartItems.Where(x => !string.IsNullOrEmpty(x.ReservationId)).ToList();

            foreach (var cartItem in inCart)
            {
                var matching = reservations.Where(x => x.Id == cartItem.ReservationId);
                if (matching.Any())
                {
                    reservations.Remove(matching.First());
                }
            }

            var toReturn = reservations.GroupBy(x => x.Date).Select(x => x.First()).ToList();

            return(Json(toReturn));
        }