/// <summary> /// Initializes a new instance of the <see cref="SearchController"/> class. /// </summary> /// <param name="marketing">The marketing.</param> /// <param name="priceListClient">The price list client.</param> /// <param name="storeClient">The store client.</param> /// <param name="catalogClient">The catalog client.</param> public SearchController(MarketingHelper marketing, PriceListClient priceListClient, StoreClient storeClient, CatalogClient catalogClient) { _marketing = marketing; _priceListClient = priceListClient; _storeClient = storeClient; _catalogClient = catalogClient; }
/// <summary> /// Initializes a new instance of the <see cref="SearchController" /> class. /// </summary> /// <param name="marketing">The marketing.</param> /// <param name="priceListClient">The price list client.</param> /// <param name="storeClient">The store client.</param> /// <param name="catalogClient">The catalog client.</param> /// <param name="searchFilter">The search filter.</param> public SearchController(MarketingHelper marketing, PriceListClient priceListClient, StoreClient storeClient, CatalogClient catalogClient, ISearchFilterService searchFilter) { _marketing = marketing; _priceListClient = priceListClient; _storeClient = storeClient; _catalogClient = catalogClient; _searchFilter = searchFilter; }
/// <summary> /// Initializes a new instance of the <see cref="AccountController" /> class. /// </summary> /// <param name="catalogClient">The catalog client.</param> /// <param name="userClient">The user client.</param> /// <param name="countryClient">The country client.</param> /// <param name="orderClient">The order client.</param> /// <param name="settingsClient">The settings client.</param> /// <param name="identitySecurity">The web security.</param> /// <param name="orderService">The order service.</param> public AccountController(CatalogClient catalogClient, UserClient userClient, CountryClient countryClient, OrderClient orderClient, SettingsClient settingsClient, IdentityUserSecurity identitySecurity, IOrderService orderService) { _catalogClient = catalogClient; _userClient = userClient; _countryClient = countryClient; _orderClient = orderClient; _settingsClient = settingsClient; _identitySecurity = identitySecurity; _orderService = orderService; }
/// <summary> /// Initializes a new instance of the <see cref="AccountController" /> class. /// </summary> /// <param name="catalogClient">The catalog client.</param> /// <param name="userClient">The user client.</param> /// <param name="countryClient">The country client.</param> /// <param name="orderClient">The order client.</param> /// <param name="settingsClient">The settings client.</param> /// <param name="webSecurity">The web security.</param> /// <param name="oAuthSecurity">The o authentication security.</param> /// <param name="orderService">The order service.</param> public AccountController(CatalogClient catalogClient, UserClient userClient, CountryClient countryClient, OrderClient orderClient, SettingsClient settingsClient, IUserSecurity webSecurity, IOAuthWebSecurity oAuthSecurity, IOrderService orderService) { _catalogClient = catalogClient; _userClient = userClient; _countryClient = countryClient; _orderClient = orderClient; _settingsClient = settingsClient; _webSecurity = webSecurity; _oAuthSecurity = oAuthSecurity; _orderService = orderService; }
private void ValidateItems() { //We don't need to validate quantity in the wish list var orderForms = CurrentOrderGroup.OrderForms.ToArray(); var lineItems = orderForms.SelectMany(x => x.LineItems.ToArray()); var validLineItems = lineItems.Where(x => !String.IsNullOrEmpty(x.CatalogItemId) && !x.CatalogItemId.StartsWith("@")); foreach (var lineItem in validLineItems) { var changeQtyReason = new List<string>(); bool isUsingBackordersAndPreorders; var newQty = GetNewLineItemQty(lineItem, changeQtyReason, out isUsingBackordersAndPreorders); if (newQty == 0) { // Remove item if it reached this stage RegisterWarning(WorkflowMessageCodes.ITEM_NOT_AVAILABLE, lineItem, String.Format("Item \"{0}\" has been removed from the cart because it is no longer available", lineItem.DisplayName)); DeleteLineItemFromShipments(lineItem); lineItem.OrderForm.LineItems.Remove(lineItem); } else { var delta = lineItem.Quantity - newQty; if (delta != 0) { lineItem.Quantity -= delta; ChangeShipmentsLineItemQty(lineItem, delta); RegisterWarning(WorkflowMessageCodes.ITEM_QTY_CHANGED, lineItem, String.Format("Item \"{0}\" quantity has been changed", lineItem.DisplayName)); } // update Shipment Status if LineItem InStockQuantity was insufficient and Backorders/Preorders were used. if (isUsingBackordersAndPreorders) { var catalogHelper = new CatalogClient(CatalogRepository, null, null, CacheRepository, null); var catalogItem = catalogHelper.GetItem(lineItem.CatalogItemId); if (catalogItem != null && catalogItem.TrackInventory) { var allShipmentContainingLineItem = orderForms .SelectMany(x => x.Shipments) .Where(x => x.ShipmentItems.Select(si => si.LineItem).Contains(lineItem)) .ToList(); allShipmentContainingLineItem.ForEach(x => x.Status = ShipmentStatus.AwaitingInventory.ToString()); } } } } }
private void CalculateTaxes(OrderGroup order) { var catalogHelper = new CatalogClient(CatalogRepository, null, null, CacheRepository, null); foreach (var form in order.OrderForms) { decimal totalTaxes = 0; foreach (var shipment in form.Shipments) { decimal itemTax = 0; decimal shippingTax = 0; foreach (var shipItem in shipment.ShipmentItems) { if (shipItem.LineItem == null) { continue; } decimal lineItemTaxTotal = 0m; // Try getting an address var address = GetAddressByName(form, shipment.ShippingAddressId); if (address != null) // no taxes if there is no address { // Try getting an item var item = catalogHelper.GetItem(shipItem.LineItem.CatalogItemId); if (item != null) // no entry, no tax category, no tax { var taxCategory = item.TaxCategory; // calls the method that returns all the tax values var taxes = GetTaxes(taxCategory, Thread.CurrentThread.CurrentCulture.Name, address.CountryCode, address.StateProvince, address.PostalCode, address.RegionName, string.Empty, string.Empty, address.City); if (taxes != null && taxes.Any()) { foreach (var tax in taxes) { if (tax != null) { var taxAmount = Math.Round(shipItem.LineItem.ExtendedPrice * (tax.Percentage / 100), 2); if (tax.Tax.TaxType == (int) TaxTypes.SalesTax) { itemTax += taxAmount; lineItemTaxTotal += taxAmount; totalTaxes += taxAmount; } else if (tax.Tax.TaxType == (int) TaxTypes.ShippingTax) { shippingTax += Math.Round(shipment.ShippingCost * (tax.Percentage / 100), 2); totalTaxes += shippingTax; } } } } } } shipItem.LineItem.TaxTotal = lineItemTaxTotal; } //TODO Round taxes to money shipment.ItemTaxTotal = itemTax; shipment.ShippingTaxTotal = shippingTax; } form.TaxTotal = totalTaxes; } order.TaxTotal = order.OrderForms.Sum(x=>x.TaxTotal); }
/// <summary> /// Cart controller constructor /// </summary> /// <param name="catalogClient">Catalog client used to access catalog repository methods through caching and other helpers</param> /// <param name="countryClient">Allows to get countries from repository through caching</param> public CartController(CatalogClient catalogClient, CountryClient countryClient) { _catalogClient = catalogClient; _countryClient = countryClient; }
public StoreSearchFilterService(StoreClient client, ICustomerSessionService customerSession, CatalogClient catalogClient) { _storeClient = client; _customerSession = customerSession; _catalogClient = catalogClient; }
/// <summary> /// Initializes a new instance of the <see cref="CatalogController" /> class. /// </summary> /// <param name="catalogClient">The catalog client.</param> /// <param name="templateClient">The template client.</param> public CatalogController(CatalogClient catalogClient, DisplayTemplateClient templateClient) { _catalogClient = catalogClient; _templateClient = templateClient; }
/// <summary> /// Validates the items. /// </summary> private void ValidateItems() { var orderForms = CurrentOrderGroup.OrderForms.ToArray(); var lineItems = orderForms.SelectMany(x => x.LineItems.ToArray()); var validLineItems = lineItems.Where(x => !String.IsNullOrEmpty(x.CatalogItemId) && !x.CatalogItemId.StartsWith("@")).ToArray(); string catalogId = null; // get the store and compare if (validLineItems.Any()) { var store = new StoreClient(StoreRepository, CustomerSessionService, CacheRepository).GetStoreById(CurrentOrderGroup.StoreId); catalogId = store.Catalog; } if (!String.IsNullOrEmpty(catalogId)) { var catalogHelper = new CatalogClient(CatalogRepository, null, CustomerSessionService, CacheRepository, InventoryRepository); var catalogItemIds = (from i in validLineItems select i.CatalogItemId).ToArray(); var items = catalogHelper.GetItems(catalogItemIds); foreach (var lineItem in validLineItems) { var item = items.SingleOrDefault(i => i.ItemId.Equals(lineItem.CatalogItemId, StringComparison.OrdinalIgnoreCase)); if (item != null && catalogHelper.GetItemAvailability(item.ItemId, lineItem.FulfillmentCenterId).IsAvailable) { //Inventory Info if (item.TrackInventory) { var inventory = catalogHelper.GetItemInventory(lineItem.CatalogItemId, lineItem.FulfillmentCenterId); PopulateInventoryInfo(inventory, lineItem); } //Variation Info PopulateVariationInfo(item, lineItem); } else // remove item from the list { RemoveLineItem(lineItem); } } } else // since no catalog is associated with a store, remove all items { RemoveAllLineItems(); } }
private void AdjustStockItemQuantity(LineItem lineItem) { if (String.IsNullOrEmpty(lineItem.CatalogItemId) || lineItem.CatalogItemId.StartsWith("@")) { return; } var catalogHelper = new CatalogClient(CatalogRepository, null, CustomerSessionService, CacheRepository, InventoryRepository); var item = catalogHelper.GetItem(lineItem.CatalogItemId); if (item != null && item.TrackInventory) { var repo = InventoryRepository; var inventory = catalogHelper.GetItemInventory(lineItem.CatalogItemId, lineItem.FulfillmentCenterId, false); if (inventory != null) { if (AdjustStockInventoryQuantity(lineItem, inventory)) { repo.UnitOfWork.Commit(); } else { throw new InvalidWorkflowException(string.Format("Failed to adjust inventory for lineItem {0}", lineItem.LineItemId)); } } } }