Class OrderService
- Namespace
- Dynamicweb.Ecommerce.Orders
- Assembly
- Dynamicweb.Ecommerce.dll
The OrderService class providing methods for querying and saving The Order aggregate to and from persistence.
public class OrderService : ICacheStorage<string, Order>, ICacheStorage<string>, ICacheStorage
- Inheritance
-
OrderService
- Implements
- Inherited Members
Constructors
OrderService()
public OrderService()
Methods
CalculateDiscounts(Order)
Calculates the discounts for this Order.
If RecalculateDiscountsNeeded is
false or if Calculate is false, discounts will not be calculated.public void CalculateDiscounts(Order order)
Parameters
orderOrder- The Order.
CalculateDiscounts(Order, Language)
Calculates the discounts for this Order.
If RecalculateDiscountsNeeded is
false or if Calculate is false, discounts will not be calculated.[Obsolete("Use overload with order only instead.")]
public void CalculateDiscounts(Order order, Language language)
Parameters
CalculateDiscounts(Order, Language, Currency, Country)
[Obsolete("Use overload with order only instead.")]
public void CalculateDiscounts(Order order, Language language, Currency currency, Country country)
Parameters
CalculateShippingFee(Order, string)
Calculates shipping fees for an order given a shipping method id
public ShippingCalculationResult CalculateShippingFee(Order order, string shippingMethodId)
Parameters
Returns
Capture(Order)
Performs capture on the order and stores the resulting OrderCaptureInfo on the order.
public OrderCaptureInfo Capture(Order order)
Parameters
orderOrder- The Order.
Returns
- OrderCaptureInfo
- The generated OrderCaptureInfo object, or null if capture is not supported.
Capture(Order, long, bool)
Performs capture on the order and stores the resulting OrderCaptureInfo on the order.
public OrderCaptureInfo Capture(Order order, long amount, bool final)
Parameters
orderOrder- The Order.
amountlong- The amount that is multiplied by 100.
finalbool- The capture is final.
Returns
- OrderCaptureInfo
- The generated OrderCaptureInfo object, or null if capture is not supported.
ClearCache()
Resets all keys to the default value for objects stored in the object cache
public void ClearCache()
ClearCache(IEnumerable<string>)
Resets the specified keys to the default value for objects stored in the object cache
public void ClearCache(IEnumerable<string> keys)
Parameters
keysIEnumerable<string>- Keys to reset
ClearCache(string)
Resets the specified key to the default value for objects stored in the object cache
public void ClearCache(string key)
Parameters
keystring- Key to reset
ClearCachedPrices(Order)
Clears the cached prices.
public void ClearCachedPrices(Order order)
Parameters
orderOrder- The Order.
Complete(Order)
Sets the order complete state to true.
public void Complete(Order order)
Parameters
orderOrder- The Order.
CreateOrderLine(Order, Product, double, StockUnit, PriceInfo)
[Obsolete("Use 'Ecommerce.Services.OrderLines.Create' instead")]
public OrderLine CreateOrderLine(Order order, Product product, double quantity, StockUnit unit, PriceInfo unitPrice)
Parameters
orderOrder- The Order.
productProduct- The Product.
quantitydouble- The quantity.
unitStockUnit- The stock uint.
unitPricePriceInfo- The unit price.
Returns
CreateOrderLine(Order, string, double, PriceInfo, OrderLineType, string, string)
Adds a new OrderLine to the OrderLineCollection of the Order with the given OrderLineType and the given text.
[Obsolete("Use 'Ecommerce.Services.OrderLines.Create' instead")]
public OrderLine CreateOrderLine(Order order, string text, double quantity, PriceInfo unitPrice, OrderLineType type, string parentOrderLineId, string discountId)
Parameters
orderOrder- The Order.
textstring- The line text.
quantitydouble- The quantity.
unitPricePriceInfo- The unit price.
typeOrderLineType- The order line price.
parentOrderLineIdstring- The parent order line ID.
discountIdstring- The discount ID.
Returns
Delete(string)
Deletes the order.
public void Delete(string orderId)
Parameters
orderIdstring- The Order ID.
DowngradeToCart(Order)
Converts the order back to cart.
public void DowngradeToCart(Order order)
Parameters
orderOrder- The Order.
DowngradeToCart(Order, bool)
Converts the order back to cart.
public void DowngradeToCart(Order order, bool markDeleted)
Parameters
FindOrders(string, string, string, string, bool, string)
Finds the orders by parameters.
public IEnumerable<Order> FindOrders(string keyword, string stateId, string startdate, string enddate, bool showCart, string shopId)
Parameters
keywordstring- The search keyword.
stateIdstring- The state ID.
startdatestring- The search interval start date. Field used for search is OrderDate.
enddatestring- The search interval end date. Field used for search is OrderDate.
showCartbool- The value indicating whether the carts should be included in results or not.
shopIdstring- The shop ID.
Returns
- IEnumerable<Order>
- The collection of the Order.
ForcePriceRecalculation(Order)
Forces the recalculation of the Price.
public void ForcePriceRecalculation(Order order)
Parameters
orderOrder- The Order.
GetAll()
Gets all orders in solution.
public IEnumerable<Order> GetAll()
Returns
- IEnumerable<Order>
- The collection of the Order.
GetAllOrderVersions(string)
Gets all versions for the order.
[Obsolete("Use 'GetAllVersions' instead")]
public IEnumerable<Order> GetAllOrderVersions(string orderId)
Parameters
orderIdstring- The Order ID.
Returns
- IEnumerable<Order>
- The collection of the Order.
GetAllVersions(string)
Gets all versions for the order.
public IEnumerable<Order> GetAllVersions(string orderId)
Parameters
orderIdstring- The Order ID.
Returns
- IEnumerable<Order>
- The collection of the Order.
GetByAutoId(int)
Gets the order by auto ID.
public Order GetByAutoId(int orderAutoId)
Parameters
orderAutoIdint- The Auto ID.
Returns
GetById(string)
Gets the order by ID.
public Order GetById(string orderId)
Parameters
orderIdstring- The Order ID.
Returns
GetBySecret(string)
Gets the order by secret.
public Order GetBySecret(string secret)
Parameters
secretstring- The order secret.
Returns
GetCartFormName(string)
Gets the name of the cart form.
public string GetCartFormName(string orderId)
Parameters
orderIdstring- The Cart ID.
Returns
- string
- "CartForm_[ID]"
GetCompletedOrders(int, string, string)
Gets the compleated orders.
public IEnumerable<Order> GetCompletedOrders(int customerId, string customerNumber, string shopIds)
Parameters
customerIdint- The customer ID. Set to 0 to skip this argument.
customerNumberstring- The customer number. Set to "" to skip this argument.
shopIdsstring- The shop IDs. Set to "" to skip this argument.
Returns
- IEnumerable<Order>
- The collection of the Order.
GetCountry(Order)
Gets the country for order based on order language id.
[Obsolete("Use Order.VatCountry instead.")]
public Country GetCountry(Order order)
Parameters
orderOrder
Returns
Remarks
If order have not set language id returns default country based on default solution language or any existent country.
GetCustomerOrdersByType(int, string, OrderType, int, bool, string, DateTime)
Gets customer's orders of specified type.
public IEnumerable<Order> GetCustomerOrdersByType(int customerId, string shopIds, OrderType orderType, int recurringOrderId, bool useCustomerNumber, string orderContextIds, DateTime fromDate)
Parameters
customerIdint- The User ID.
shopIdsstring- The Shops IDs.
orderTypeOrderType- The OrderType.
recurringOrderIdint- The ID of the recerring order.
useCustomerNumberbool- If set to
true, search by customer number, otherwise search by customer ID. orderContextIdsstring- The order context IDs.
fromDateDateTime
Returns
- IEnumerable<Order>
- The collection of the Order.
GetCustomerOrdersByType(int, string, OrderType, int, bool, string, DateTime, bool)
Gets customer's orders of specified type.
public IEnumerable<Order> GetCustomerOrdersByType(int customerId, string shopIds, OrderType orderType, int recurringOrderId, bool useCustomerNumber, string orderContextIds, DateTime fromDate, bool includeImpersonation)
Parameters
customerIdint- The User ID.
shopIdsstring- The Shops IDs.
orderTypeOrderType- The OrderType.
recurringOrderIdint- The ID of the recerring order.
useCustomerNumberbool- If set to
true, search by customer number, otherwise search by customer ID. orderContextIdsstring- The order context IDs.
fromDateDateTimeincludeImpersonationbool- The orders will be retrieved for user considering users he can impersonate.
Returns
- IEnumerable<Order>
- The collection of the Order.
Remarks
The parameter "useCustomerNumber" doesn't work when IncludeImpersonation is set to true
GetCustomerOrdersByType(int, string, OrderType, int, bool, string, DateTime, bool, bool)
Gets customer's orders of specified type.
public IEnumerable<Order> GetCustomerOrdersByType(int customerId, string shopIds, OrderType orderType, int recurringOrderId, bool useCustomerNumber, string orderContextIds, DateTime fromDate, bool includeImpersonation, bool isCart)
Parameters
customerIdint- The User ID.
shopIdsstring- The Shops IDs.
orderTypeOrderType- The OrderType.
recurringOrderIdint- The ID of the recerring order.
useCustomerNumberbool- If set to
true, search by customer number, otherwise search by customer ID. orderContextIdsstring- The order context IDs.
fromDateDateTimeincludeImpersonationbool- The orders will be retrieved for user considering users he can impersonate.
isCartbool- If set to
true, search orders in cart state.
Returns
- IEnumerable<Order>
- The collection of the Order.
Remarks
The parameter "useCustomerNumber" doesn't work when IncludeImpersonation is set to true
GetCustomerUnclosedOrders(int)
Gets unclosed orders of customer.
public IEnumerable<Order> GetCustomerUnclosedOrders(int customerId)
Parameters
customerIdint- The User ID.
Returns
- IEnumerable<Order>
- The collection of the Order.
GetFeeCountry(Order)
Gets the VAT country for order based on delivery country code or customer country code.
[Obsolete("Use Order.VatCountry instead.")]
public Country GetFeeCountry(Order order)
Parameters
orderOrder
Returns
GetLastFailedRecurringOrderId(int)
Gets the last failed recurring order ID.
public string GetLastFailedRecurringOrderId(int recurringOrderId)
Parameters
recurringOrderIdint- The recurring order ID.
Returns
- string
- The Order ID.
GetOrder(int)
Gets the order by auto ID.
[Obsolete("Use 'GetByAutoId' instead")]
public Order GetOrder(int orderAutoId)
Parameters
orderAutoIdint- The Auto ID.
Returns
GetOrder(string)
Gets the order by ID.
[Obsolete("Use 'GetById' instead")]
public Order GetOrder(string orderId)
Parameters
orderIdstring- The Order ID.
Returns
GetOrderForCurrentUser(string)
Gets the order for current user.
public Order GetOrderForCurrentUser(string orderId)
Parameters
orderIdstring- The order identifier.
Returns
GetOrderForCurrentUser(string, bool)
Gets the order for current user.
public Order GetOrderForCurrentUser(string orderId, bool includeImpersonation)
Parameters
Returns
GetOrders()
Gets all orders in solution.
[Obsolete("Use 'GetAll' instead")]
public IEnumerable<Order> GetOrders()
Returns
- IEnumerable<Order>
- The collection of the Order.
GetOrdersBySearch(OrderSearchFilter)
Gets orders by search settings
public OrderSearchResult GetOrdersBySearch(OrderSearchFilter filter)
Parameters
filterOrderSearchFilter- Search filter
Returns
GetPreviousOrderIds(int)
Gets the previous recurring orders IDs.
public IEnumerable<string> GetPreviousOrderIds(int recurringOrderId)
Parameters
recurringOrderIdint- The recurring order ID.
Returns
- IEnumerable<string>
- The collection of the order IDs.
GetProductOrderLines(Order)
Gets an OrderLineCollection containing all OrderLine objects where OrderLine.Product is not null.
public OrderLineCollection GetProductOrderLines(Order order)
Parameters
orderOrder
Returns
Remarks
GetPropertyType(Order, string)
Gets the property type.
public string GetPropertyType(Order order, string propertyName)
Parameters
Returns
- string
- The property type.
GetPropertyValue(Order, string)
Gets the property value.
public object GetPropertyValue(Order order, string propertyName)
Parameters
Returns
- object
- The property value.
GetTopOrders(int)
Gets the specified number of the top Orders, ordered by creation date (descending), then by order ID (descending).
public IEnumerable<Order> GetTopOrders(int count)
Parameters
countint- The count of Orders.
Returns
- IEnumerable<Order>
- The collection of the Order.
GetTotalPurchasesByCustomerId(int, DateTime, Currency)
Gets the total purchase price by customer ID.
public PriceInfo GetTotalPurchasesByCustomerId(int customerId, DateTime fromDate, Currency priceCurrency)
Parameters
customerIdint- The User ID.
fromDateDateTime- The search interval start date. Field used for search is OrderDate.
priceCurrencyCurrency- The Currency.
Returns
IsComplete(string)
Gets the value determines whether the order is completed or not.
public bool IsComplete(string orderId)
Parameters
orderIdstring- The Order ID.
Returns
IsOrderComplete(string)
Gets the value determines whether the order is completed or not.
[Obsolete("Use 'IsComplete' instead")]
public bool IsOrderComplete(string orderId)
Parameters
orderIdstring- The Order ID.
Returns
MarkOrderAsDeleted(Order)
Marks the Order as deleted and set deleted order state if it exists.
public void MarkOrderAsDeleted(Order order)
Parameters
orderOrder- The Order.
Remarks
If order has related RecurringOrder the recurring is stopped.
OrderLineBuilder(Order, OrderLineBuilderConfig)
Builds an OrderLine based on the given OrderLineBuilderConfig.
[Obsolete("Use 'Ecommerce.Services.OrderLines.OrderLineBuilder' instead")]
public OrderLine OrderLineBuilder(Order order, OrderLineBuilderConfig builderConfiguration)
Parameters
orderOrderbuilderConfigurationOrderLineBuilderConfig- The builder configuration.
Returns
RemoveNoneActiveProducts(Order)
Removes all orderlines that is of type Product and that no longer exist in the database. Also removes products according to the control panel settings: Active, on stock, price is zero.
public void RemoveNoneActiveProducts(Order order)
Parameters
orderOrder- The Order.
RemoveOrderCache(string)
Removes order and its order lines from cache.
public void RemoveOrderCache(string orderId)
Parameters
orderIdstring- The Order ID.
Save(Order)
Saves the order.
public void Save(Order order)
Parameters
orderOrder- The order.
Save(Order, bool)
Saves the order.
public void Save(Order order, bool saveOldVersion)
Parameters
SaveGatewayResult(Order)
Saves the gateway result.
public void SaveGatewayResult(Order order)
Parameters
orderOrder- The Order.
SendEmail(Order, ref PageView, string, IEnumerable<string>, string, string, ref Template)
Sends the mail to the specified addresses.
public bool SendEmail(Order order, ref PageView pageView, string subject, IEnumerable<string> toMailAddresses, string fromMailAddress, string fromMailName, ref Template mailTemplate)
Parameters
orderOrder- The Order.
pageViewPageView- The page view.
subjectstring- The subject.
toMailAddressesIEnumerable<string>- The recipients email addresses.
fromMailAddressstring- The sender email address.
fromMailNamestring- The sender name.
mailTemplateTemplate- The templpate.
Returns
- bool
trueif mail was successfully sent, otherwisefalse.
SendEmail(Order, ref PageView, string, string, string, string, ref Template)
Sends the mail to the specified address.
public bool SendEmail(Order order, ref PageView pageView, string subject, string toMailAddress, string fromMailAddress, string fromMailName, ref Template mailTemplate)
Parameters
orderOrder- The Order.
pageViewPageView- The page view.
subjectstring- The subject.
toMailAddressstring- The recipient email address.
fromMailAddressstring- The sender email address.
fromMailNamestring- The sender name.
mailTemplateTemplate- The templpate.
Returns
- bool
trueif mail was successfully sent, otherwisefalse.
SetDefaultState(Order)
Set default state for the order, cart or quote.
public void SetDefaultState(Order order)
Parameters
orderOrder- The Order.
SetOrderComplete(Order)
Sets the order complete state to true.
[Obsolete("Use 'Complete' instead")]
public void SetOrderComplete(Order order)
Parameters
orderOrder- The Order.
SetUserDetailsOnOrder(Order, User, bool)
public void SetUserDetailsOnOrder(Order order, User user, bool doSave)
Parameters
UpdateCartState(Order, string)
Updates the cart state.
public void UpdateCartState(Order cart, string stateId)
Parameters
UpdateCartToOrder(Order)
Updates the cart to order.
public void UpdateCartToOrder(Order order)
Parameters
orderOrder- The Order.
UpdateCartToOrder(Order, bool)
public void UpdateCartToOrder(Order order, bool sendNotifyOrderStateChangedMail)
Parameters
UpdateCartToQuote(Order)
Updates the cart to quote.
public void UpdateCartToQuote(Order order)
Parameters
orderOrder- The Order.
UpdateGatewayResult(Order, bool)
Updates the gateway result.
public void UpdateGatewayResult(Order order, bool setComplete)
Parameters
orderOrder- The Order.
setCompletebool- If set to
true, the Order complete state will be also set totrue.
UpdateOrderId(Order, string)
Updates the Order ID.
public void UpdateOrderId(Order order, string newOrderId)
Parameters
UpdateQuoteState(Order, string)
Updates the quote state.
public void UpdateQuoteState(Order order, string stateId)
Parameters
UpdateStepInfo(Order)
Updates the order step information.
public void UpdateStepInfo(Order order)
Parameters
orderOrder- The Order.
UpdateVat(Order, double)
Updates the order VAT.
public void UpdateVat(Order order, double newVat)
Parameters
UpdateVat(Order, double, double)
Updates the order VAT.
public void UpdateVat(Order order, double newVat, double newVatPercent)
Parameters
orderOrder- The Order.
newVatdouble- The new VAT value.
newVatPercentdouble- The new VAT percent value.
ValidatePricesInDatabase(Order, ref double, ref double, ref double)
Validates the prices in database.
public bool ValidatePricesInDatabase(Order order, ref double orderPrice, ref double orderlinePrice, ref double priceDifference)
Parameters
orderOrder- The Order.
orderPricedouble- Sets the order price if prices are invalid.
orderlinePricedouble- Sets the order lines price if prices are invalid.
priceDifferencedouble- Sets the price difference if prices are invalid.
Returns
- bool
trueif prices are valid, otherwisefalse.