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 Dynamicweb.Ecommerce.Orders.Order.RecalculateDiscountsNeeded is false or if Calculate is false, discounts will not be calculated.
public void CalculateDiscounts(Order order)
Parameters
orderOrderThe Order.
CalculateDiscounts(Order, bool)
Calculates the discounts for this Order.
If Dynamicweb.Ecommerce.Orders.Order.RecalculateDiscountsNeeded is false or if Calculate is false, discounts will not be calculated.
public void CalculateDiscounts(Order order, bool forceCalculation)
Parameters
CalculatePaymentFee(Order, string)
Calculates payment fee for an order given a payment method id
public PriceInfo CalculatePaymentFee(Order order, string paymentMethodId)
Parameters
Returns
Exceptions
- ArgumentNullException
Throws if order is null
CalculateShippingFee(Order, string)
Calculates shipping fees for an order given a shipping method id
public ShippingCalculationResult CalculateShippingFee(Order order, string shippingMethodId)
Parameters
Returns
CanRegisterNewRma(Order)
Indicates if this order allows new RMAs to be registered.
public virtual bool CanRegisterNewRma(Order order)
Parameters
orderOrderThe order
Returns
Capture(Order)
Performs capture on the order and stores the resulting OrderCaptureInfo on the order.
public OrderCaptureInfo Capture(Order order)
Parameters
orderOrderThe 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
orderOrderThe Order.
amountlongThe amount that is multiplied by 100.
finalboolThe 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
keystringKey to reset
ClearCachedPrices(Order)
Clears the cached prices.
public void ClearCachedPrices(Order order)
Parameters
orderOrderThe Order.
Complete(Order)
Sets the order complete state to true.
public void Complete(Order order)
Parameters
orderOrderThe Order.
Delete(string)
Deletes the order.
public void Delete(string orderId)
Parameters
orderIdstringThe Order ID.
DowngradeToCart(Order)
Converts the order back to cart.
public void DowngradeToCart(Order order)
Parameters
orderOrderThe 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
keywordstringThe search keyword.
stateIdstringThe state ID.
startdatestringThe search interval start date. Field used for search is OrderDate.
enddatestringThe search interval end date. Field used for search is OrderDate.
showCartboolThe value indicating whether the carts should be included in results or not.
shopIdstringThe shop ID.
Returns
- IEnumerable<Order>
The collection of the Order.
ForcePriceRecalculation(Order)
Forces the recalculation of the Price.
public void ForcePriceRecalculation(Order order)
Parameters
orderOrderThe Order.
GetAll()
Gets all orders in solution.
public IEnumerable<Order> GetAll()
Returns
- IEnumerable<Order>
The collection of the Order.
GetAllVersions(string)
Gets all versions for the order.
public IEnumerable<Order> GetAllVersions(string orderId)
Parameters
orderIdstringThe Order ID.
Returns
- IEnumerable<Order>
The collection of the Order.
GetByAutoId(int)
Gets the order by auto ID.
public Order GetByAutoId(int orderAutoId)
Parameters
orderAutoIdintThe Auto ID.
Returns
GetById(string)
Gets the order by ID.
public Order GetById(string orderId)
Parameters
orderIdstringThe Order ID.
Returns
GetBySecret(string)
Gets the order by secret.
public Order GetBySecret(string secret)
Parameters
secretstringThe order secret.
Returns
GetCartFormName(string)
Gets the name of the cart form.
public string GetCartFormName(string orderId)
Parameters
orderIdstringThe 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
customerIdintThe customer ID. Set to 0 to skip this argument.
customerNumberstringThe customer number. Set to "" to skip this argument.
shopIdsstringThe shop IDs. Set to "" to skip this argument.
Returns
- IEnumerable<Order>
The collection of the Order.
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
customerIdintThe User ID.
shopIdsstringThe Shops IDs.
orderTypeOrderTypeThe OrderType.
recurringOrderIdintThe ID of the recerring order.
useCustomerNumberboolIf set to
true, search by customer number, otherwise search by customer ID.orderContextIdsstringThe 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
customerIdintThe User ID.
shopIdsstringThe Shops IDs.
orderTypeOrderTypeThe OrderType.
recurringOrderIdintThe ID of the recerring order.
useCustomerNumberboolIf set to
true, search by customer number, otherwise search by customer ID.orderContextIdsstringThe order context IDs.
fromDateDateTimeincludeImpersonationboolThe 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
customerIdintThe User ID.
shopIdsstringThe Shops IDs.
orderTypeOrderTypeThe OrderType.
recurringOrderIdintThe ID of the recerring order.
useCustomerNumberboolIf set to
true, search by customer number, otherwise search by customer ID.orderContextIdsstringThe order context IDs.
fromDateDateTimeincludeImpersonationboolThe orders will be retrieved for user considering users he can impersonate.
isCartboolIf 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
GetCustomerOrdersByType(int, string, OrderType, int, bool, string, DateTime, bool, 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, bool includeUserAndSecondaryUserIds)
Parameters
customerIdintThe User ID.
shopIdsstringThe Shops IDs.
orderTypeOrderTypeThe OrderType.
recurringOrderIdintThe ID of the recerring order.
useCustomerNumberboolIf set to
true, search by customer number, otherwise search by customer ID.orderContextIdsstringThe order context IDs.
fromDateDateTimeincludeImpersonationboolThe orders will be retrieved for user considering users he can impersonate.
isCartboolIf set to
true, search orders in cart state.includeUserAndSecondaryUserIdsboolThe orders will be retrieved for user while impersonating.
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
customerIdintThe User ID.
Returns
- IEnumerable<Order>
The collection of the Order.
GetLastFailedRecurringOrderId(int)
Gets the last failed recurring order ID.
public string GetLastFailedRecurringOrderId(int recurringOrderId)
Parameters
recurringOrderIdintThe recurring order ID.
Returns
- string
The Order ID.
GetOrderForCurrentUser(string)
Gets the order for current user.
public Order GetOrderForCurrentUser(string orderId)
Parameters
orderIdstringThe order identifier.
Returns
GetOrderForCurrentUser(string, bool)
Gets the order for current user.
public Order GetOrderForCurrentUser(string orderId, bool includeImpersonation)
Parameters
Returns
GetOrdersByIds(IEnumerable<string>)
Gets the orders by IDs
public IEnumerable<Order> GetOrdersByIds(IEnumerable<string> ids)
Parameters
idsIEnumerable<string>The ids of orders
Returns
- IEnumerable<Order>
The collection of the Order.
GetOrdersBySearch(OrderSearchFilter)
Gets orders by search settings
public OrderSearchResult GetOrdersBySearch(OrderSearchFilter filter)
Parameters
filterOrderSearchFilterSearch filter
Returns
GetPreviousOrderIds(int)
Gets the previous recurring orders IDs.
public IEnumerable<string> GetPreviousOrderIds(int recurringOrderId)
Parameters
recurringOrderIdintThe 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
The function returns order lines of type: Product, Fixed, PointProduct and GiftCard.
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
countintThe 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
customerIdintThe User ID.
fromDateDateTimeThe search interval start date. Field used for search is OrderDate.
priceCurrencyCurrencyThe Currency.
Returns
IsComplete(string)
Gets the value determines whether the order is completed or not.
public bool IsComplete(string orderId)
Parameters
orderIdstringThe Order ID.
Returns
MarkOrderAsDeleted(Order)
Marks the Order as deleted and set deleted order state if it exists.
public void MarkOrderAsDeleted(Order order)
Parameters
orderOrderThe Order.
Remarks
If order has related RecurringOrder the recurring is stopped.
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
orderOrderThe Order.
RemoveOrderCache(string)
Removes order and its order lines from cache.
public void RemoveOrderCache(string orderId)
Parameters
orderIdstringThe Order ID.
Save(Order)
Saves the order.
public void Save(Order order)
Parameters
orderOrderThe 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
orderOrderThe 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
orderOrderThe Order.
pageViewPageViewThe page view.
subjectstringThe subject.
toMailAddressesIEnumerable<string>The recipients email addresses.
fromMailAddressstringThe sender email address.
fromMailNamestringThe sender name.
mailTemplateTemplateThe 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
orderOrderThe Order.
pageViewPageViewThe page view.
subjectstringThe subject.
toMailAddressstringThe recipient email address.
fromMailAddressstringThe sender email address.
fromMailNamestringThe sender name.
mailTemplateTemplateThe 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
orderOrderThe 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
orderOrderThe 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
orderOrderThe Order.
UpdateGatewayResult(Order, bool)
Updates the gateway result.
public void UpdateGatewayResult(Order order, bool setComplete)
Parameters
orderOrderThe Order.
setCompleteboolIf set to
true, the Order complete state will be also set totrue.
UpdateLedgerState(Order, string)
Updates the ledger state.
public void UpdateLedgerState(Order order, string stateId)
Parameters
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
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
orderOrderThe Order.
newVatdoubleThe new VAT value.
newVatPercentdoubleThe 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
orderOrderThe Order.
orderPricedoubleSets the order price if prices are invalid.
orderlinePricedoubleSets the order lines price if prices are invalid.
priceDifferencedoubleSets the price difference if prices are invalid.
Returns
- bool
trueif prices are valid, otherwisefalse.