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
order
OrderThe 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
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
order
OrderThe order
Returns
Capture(Order)
Performs capture on the order and stores the resulting OrderCaptureInfo on the order.
public OrderCaptureInfo Capture(Order order)
Parameters
order
OrderThe 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
order
OrderThe Order.
amount
longThe amount that is multiplied by 100.
final
boolThe 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
keys
IEnumerable<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
key
stringKey to reset
ClearCachedPrices(Order)
Clears the cached prices.
public void ClearCachedPrices(Order order)
Parameters
order
OrderThe Order.
Complete(Order)
Sets the order complete state to true.
public void Complete(Order order)
Parameters
order
OrderThe Order.
Delete(string)
Deletes the order.
public void Delete(string orderId)
Parameters
orderId
stringThe Order ID.
DowngradeToCart(Order)
Converts the order back to cart.
public void DowngradeToCart(Order order)
Parameters
order
OrderThe 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
keyword
stringThe search keyword.
stateId
stringThe state ID.
startdate
stringThe search interval start date. Field used for search is OrderDate.
enddate
stringThe search interval end date. Field used for search is OrderDate.
showCart
boolThe value indicating whether the carts should be included in results or not.
shopId
stringThe shop ID.
Returns
- IEnumerable<Order>
The collection of the Order.
ForcePriceRecalculation(Order)
Forces the recalculation of the Price.
public void ForcePriceRecalculation(Order order)
Parameters
order
OrderThe 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
orderId
stringThe Order ID.
Returns
- IEnumerable<Order>
The collection of the Order.
GetByAutoId(int)
Gets the order by auto ID.
public Order GetByAutoId(int orderAutoId)
Parameters
orderAutoId
intThe Auto ID.
Returns
GetById(string)
Gets the order by ID.
public Order GetById(string orderId)
Parameters
orderId
stringThe Order ID.
Returns
GetBySecret(string)
Gets the order by secret.
public Order GetBySecret(string secret)
Parameters
secret
stringThe order secret.
Returns
GetCartFormName(string)
Gets the name of the cart form.
public string GetCartFormName(string orderId)
Parameters
orderId
stringThe 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
customerId
intThe customer ID. Set to 0 to skip this argument.
customerNumber
stringThe customer number. Set to "" to skip this argument.
shopIds
stringThe 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
customerId
intThe User ID.
shopIds
stringThe Shops IDs.
orderType
OrderTypeThe OrderType.
recurringOrderId
intThe ID of the recerring order.
useCustomerNumber
boolIf set to
true
, search by customer number, otherwise search by customer ID.orderContextIds
stringThe order context IDs.
fromDate
DateTime
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
customerId
intThe User ID.
shopIds
stringThe Shops IDs.
orderType
OrderTypeThe OrderType.
recurringOrderId
intThe ID of the recerring order.
useCustomerNumber
boolIf set to
true
, search by customer number, otherwise search by customer ID.orderContextIds
stringThe order context IDs.
fromDate
DateTimeincludeImpersonation
boolThe 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
customerId
intThe User ID.
shopIds
stringThe Shops IDs.
orderType
OrderTypeThe OrderType.
recurringOrderId
intThe ID of the recerring order.
useCustomerNumber
boolIf set to
true
, search by customer number, otherwise search by customer ID.orderContextIds
stringThe order context IDs.
fromDate
DateTimeincludeImpersonation
boolThe orders will be retrieved for user considering users he can impersonate.
isCart
boolIf 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
customerId
intThe User ID.
shopIds
stringThe Shops IDs.
orderType
OrderTypeThe OrderType.
recurringOrderId
intThe ID of the recerring order.
useCustomerNumber
boolIf set to
true
, search by customer number, otherwise search by customer ID.orderContextIds
stringThe order context IDs.
fromDate
DateTimeincludeImpersonation
boolThe orders will be retrieved for user considering users he can impersonate.
isCart
boolIf set to
true
, search orders in cart state.includeUserAndSecondaryUserIds
boolThe 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
customerId
intThe 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
recurringOrderId
intThe recurring order ID.
Returns
- string
The Order ID.
GetOrderForCurrentUser(string)
Gets the order for current user.
public Order GetOrderForCurrentUser(string orderId)
Parameters
orderId
stringThe 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
ids
IEnumerable<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
filter
OrderSearchFilterSearch filter
Returns
GetPreviousOrderIds(int)
Gets the previous recurring orders IDs.
public IEnumerable<string> GetPreviousOrderIds(int recurringOrderId)
Parameters
recurringOrderId
intThe 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
order
Order
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
count
intThe 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
customerId
intThe User ID.
fromDate
DateTimeThe search interval start date. Field used for search is OrderDate.
priceCurrency
CurrencyThe Currency.
Returns
IsComplete(string)
Gets the value determines whether the order is completed or not.
public bool IsComplete(string orderId)
Parameters
orderId
stringThe Order ID.
Returns
MarkOrderAsDeleted(Order)
Marks the Order as deleted and set deleted order state if it exists.
public void MarkOrderAsDeleted(Order order)
Parameters
order
OrderThe 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
order
OrderThe Order.
RemoveOrderCache(string)
Removes order and its order lines from cache.
public void RemoveOrderCache(string orderId)
Parameters
orderId
stringThe Order ID.
Save(Order)
Saves the order.
public void Save(Order order)
Parameters
order
OrderThe 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
order
OrderThe 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
order
OrderThe Order.
pageView
PageViewThe page view.
subject
stringThe subject.
toMailAddresses
IEnumerable<string>The recipients email addresses.
fromMailAddress
stringThe sender email address.
fromMailName
stringThe sender name.
mailTemplate
TemplateThe templpate.
Returns
- bool
true
if 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
order
OrderThe Order.
pageView
PageViewThe page view.
subject
stringThe subject.
toMailAddress
stringThe recipient email address.
fromMailAddress
stringThe sender email address.
fromMailName
stringThe sender name.
mailTemplate
TemplateThe templpate.
Returns
- bool
true
if mail was successfully sent, otherwisefalse
.
SetDefaultState(Order)
Set default state for the order, cart or quote.
public void SetDefaultState(Order order)
Parameters
order
OrderThe 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
order
OrderThe 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
order
OrderThe Order.
UpdateGatewayResult(Order, bool)
Updates the gateway result.
public void UpdateGatewayResult(Order order, bool setComplete)
Parameters
order
OrderThe Order.
setComplete
boolIf 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
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
order
OrderThe Order.
newVat
doubleThe new VAT value.
newVatPercent
doubleThe 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
order
OrderThe Order.
orderPrice
doubleSets the order price if prices are invalid.
orderlinePrice
doubleSets the order lines price if prices are invalid.
priceDifference
doubleSets the price difference if prices are invalid.
Returns
- bool
true
if prices are valid, otherwisefalse
.