Table of Contents

Class DiscountService

Namespace
Dynamicweb.Ecommerce.Orders.Discounts
Assembly
Dynamicweb.Ecommerce.dll
The DiscountService class providing methods for querying and saving The Discount aggregate to and from persistence.
public class DiscountService : ICacheStorage<int, Discount>, ICacheStorage<int>, ICacheStorage
Inheritance
DiscountService
Implements
Inherited Members

Methods

ClearCache()

Clears the cache.
public void ClearCache()

ClearCache(IEnumerable<int>)

Resets the specified keys to the default value for objects stored in the object cache
public void ClearCache(IEnumerable<int> keys)

Parameters

keys IEnumerable<int>
Keys to reset

ClearCache(int)

Resets the specified key to the default value for objects stored in the object cache
public void ClearCache(int key)

Parameters

key int
Key to reset

Delete(int)

Deletes the discount and its translations.
public void Delete(int discountId)

Parameters

discountId int
The discount ID.

GetActiveOrderAndOrderInclusiveDiscounts()

Gets active order and order inclusive discounts.
public IEnumerable<Discount> GetActiveOrderAndOrderInclusiveDiscounts()

Returns

IEnumerable<Discount>

GetActiveOrderInclusiveDiscounts()

Gets active order inclusive discounts.
public IEnumerable<Discount> GetActiveOrderInclusiveDiscounts()

Returns

IEnumerable<Discount>

GetActiveOrderLineDiscounts()

Gets active order line discounts.
public IEnumerable<Discount> GetActiveOrderLineDiscounts()

Returns

IEnumerable<Discount>

GetApplicableDiscountsForProduct(string, string, string, Currency, User)

Gets the discounts for a given product in a given context
[Obsolete("Do not use")]
public IEnumerable<Discount> GetApplicableDiscountsForProduct(string productId, string variantId, string languageId, Currency currency, User user)

Parameters

productId string
The id of the product.
variantId string
The variant id of the product. Can be null
languageId string
The languageid. Retrieves the discounts in the specified language and is used for checks as well
currency Currency
The currency. Used for checking discounts for the correct currency
user User
The user. Used for checking if discounts are valid for the given user

Returns

IEnumerable<Discount>
System.Double.

Remarks

Retrieves a checked list of product discounts that are applicable for a given product. If the discount has rules for curreny, country code, user and language and values ared passed to this method, the appropiate checks are made. If a discount has limitation in order totals and quantity, order time, order country, shipping and payment and other order related information, these checks are not performed

GetDiscount(int)

Gets the discount.
public Discount GetDiscount(int discountId)

Parameters

discountId int

Returns

Discount
The Discount, or null if discount was not found.

GetDiscountGiven(Discount, Currency)

Gets the discount given for a discount in the specified currency.
public double GetDiscountGiven(Discount discount, Currency currency)

Parameters

discount Discount
The discount.
currency Currency
The currency.

Returns

double
System.Double.

Remarks

If a discount have been given in more than one currency, only the discount for the specified currency is returned. Discounts are not converted from other currencies

GetDiscountGivenTotal(DateTime)

Gets the information about discounts given since the specified date.
public DiscountGivenTotal GetDiscountGivenTotal(DateTime startDate)

Parameters

startDate DateTime
The start date.

Returns

DiscountGivenTotal
The DiscountGivenTotal

GetDiscounts()

Gets all discounts.
public IEnumerable<Discount> GetDiscounts()

Returns

IEnumerable<Discount>
The collection of the Discount.

GetDiscounts(DiscountApplyType)

Gets the discounts with specified DiscountApplyType.
[Obsolete("Consider to use GetActiveOrderLineDiscounts, GetActiveOrderAndOrderInclusiveDiscounts or GetActiveOrderInclusiveDiscounts instead.")]
public IEnumerable<Discount> GetDiscounts(DiscountApplyType orderDiscountType)

Parameters

orderDiscountType DiscountApplyType
The DiscountApplyType.

Returns

IEnumerable<Discount>
The collection of the Discount.

GetDiscounts(Group, bool)

public IEnumerable<Discount> GetDiscounts(Group group, bool excludingDiscount)

Parameters

group Group
excludingDiscount bool

Returns

IEnumerable<Discount>

GetDiscounts(Product, bool)

public IEnumerable<Discount> GetDiscounts(Product product, bool excludingDiscount)

Parameters

product Product
excludingDiscount bool

Returns

IEnumerable<Discount>

GetDiscounts(int, int, SortBy, SortDirection)

Gets the discounts sorted by the specified comparer in the specified zero-indexed range.
[Obsolete("Use GetDiscounts(rangeStart, rangeEnd, sortBy, sortDirection, totalCount) instead")]
public IEnumerable<Discount> GetDiscounts(int rangeStart, int rangeEnd, SortBy sortBy, SortDirection sortDirection)

Parameters

rangeStart int
The start index.
rangeEnd int
The end index.
sortBy SortBy
The sort by.
sortDirection SortDirection
The sort direction.

Returns

IEnumerable<Discount>
The IEnumerable<T>.

GetDiscounts(int, int, SortBy, SortDirection, bool, IEnumerable<Shop>)

Gets the discounts sorted by the specified comparer in the specified zero-indexed range.
[Obsolete("Use GetDiscounts(rangeStart, rangeEnd, sortBy, sortDirection, assignableFromProducts, shops, discountsCount) instead")]
public IEnumerable<Discount> GetDiscounts(int rangeStart, int rangeEnd, SortBy sortBy, SortDirection sortDirection, bool assignableFromProducts, IEnumerable<Shop> shops)

Parameters

rangeStart int
The start index.
rangeEnd int
The end index.
sortBy SortBy
The sort by.
sortDirection SortDirection
The sort direction.
assignableFromProducts bool
The aasignable from products.
shops IEnumerable<Shop>
The shops.

Returns

IEnumerable<Discount>
The IEnumerable<T>.

GetDiscounts(int, int, SortBy, SortDirection, bool, IEnumerable<Shop>, ref int)

Gets the discounts sorted by the specified comparer in the specified zero-indexed range.
public IEnumerable<Discount> GetDiscounts(int rangeStart, int rangeEnd, SortBy sortBy, SortDirection sortDirection, bool assignableFromProducts, IEnumerable<Shop> shops, ref int totalCount)

Parameters

rangeStart int
The start index.
rangeEnd int
The end index.
sortBy SortBy
The sort by.
sortDirection SortDirection
The sort direction.
assignableFromProducts bool
The aasignable from products.
shops IEnumerable<Shop>
The shops.
totalCount int
Returns the total count of discounts.

Returns

IEnumerable<Discount>
The IEnumerable<T>.

GetDiscounts(int, int, SortBy, SortDirection, ref int)

Gets the discounts sorted by the specified comparer in the specified zero-indexed range.
public IEnumerable<Discount> GetDiscounts(int rangeStart, int rangeEnd, SortBy sortBy, SortDirection sortDirection, ref int totalCount)

Parameters

rangeStart int
The start index.
rangeEnd int
The end index.
sortBy SortBy
The sort by.
sortDirection SortDirection
The sort direction.
totalCount int
Returns the total count of discounts.

Returns

IEnumerable<Discount>
The IEnumerable<T>.

GetDiscounts(int, int, SortBy, SortDirection, string, ref int)

Gets the discounts sorted by the specified comparer in the specified zero-indexed range.
public IEnumerable<Discount> GetDiscounts(int rangeStart, int rangeEnd, SortBy sortBy, SortDirection sortDirection, string shopId, ref int totalCount)

Parameters

rangeStart int
The start index.
rangeEnd int
The end index.
sortBy SortBy
The sort by.
sortDirection SortDirection
The sort direction.
shopId string
The shop ID.
totalCount int
Returns the total count of discounts.

Returns

IEnumerable<Discount>
The IEnumerable<T>.

GetDiscountsGiven(IEnumerable<Discount>)

Gets the discounts given for the specified list of discounts.
public IEnumerable<DiscountGiven> GetDiscountsGiven(IEnumerable<Discount> discounts)

Parameters

discounts IEnumerable<Discount>
The discounts.

Returns

IEnumerable<DiscountGiven>
IEnumerable(Of DiscountGiven).

Remarks

One item is returned for each discount and currency combination

GetDiscountTranslations(int)

Gets all translations for the discount.
[Obsolete("Use GetDiscount and then use the Translations property on the discount.")]
public IEnumerable<DiscountTranslation> GetDiscountTranslations(int discountId)

Parameters

discountId int

Returns

IEnumerable<DiscountTranslation>
The collection of the DiscountTranslation.

GetGroupDiscounts(Product, bool)

public IEnumerable<Discount> GetGroupDiscounts(Product product, bool excludingDiscount)

Parameters

product Product
excludingDiscount bool

Returns

IEnumerable<Discount>

GetLoyaltyDiscountPrice(Order, double)

Gets the first Loyalty discount which is applicable for order and calculate the loyalty points cost based on the discount rate.
public PriceInfo GetLoyaltyDiscountPrice(Order order, double points)

Parameters

order Order
The order where you wish to apply the discount.
points double
The number of loyalty points to calculate their cost.

Returns

PriceInfo
The PriceInfo object for the loyalty points cost.

GetOrderCountByEmail(Discount, string)

public virtual int GetOrderCountByEmail(Discount discount, string email)

Parameters

discount Discount
email string

Returns

int

GetOrderCountByUserId(Discount, int)

public virtual int GetOrderCountByUserId(Discount discount, int userid)

Parameters

discount Discount
userid int

Returns

int

GetOrderDiscounts(int, int, SortBy, SortDirection, ref int)

Gets the order discounts (inclusive and exclusive) sorted by the specified comparer in the specified zero-indexed range.
public IEnumerable<Discount> GetOrderDiscounts(int rangeStart, int rangeEnd, SortBy sortBy, SortDirection sortDirection, ref int totalCount)

Parameters

rangeStart int
The start index.
rangeEnd int
The end index.
sortBy SortBy
The sort by.
sortDirection SortDirection
The sort direction.
totalCount int
Returns the total count of discounts.

Returns

IEnumerable<Discount>
The IEnumerable<T>.

GetOrderDiscounts(int, int, SortBy, SortDirection, string, ref int)

Gets the order discounts (inclusive and exclusive) sorted by the specified comparer in the specified zero-indexed range.
public IEnumerable<Discount> GetOrderDiscounts(int rangeStart, int rangeEnd, SortBy sortBy, SortDirection sortDirection, string shopId, ref int totalCount)

Parameters

rangeStart int
The start index.
rangeEnd int
The end index.
sortBy SortBy
The sort by.
sortDirection SortDirection
The sort direction.
shopId string
The shop ID.
totalCount int
Returns the total count of discounts.

Returns

IEnumerable<Discount>
The IEnumerable<T>.

GetProductDiscounts(int, int, SortBy, SortDirection, ref int)

Gets the product discounts (orderline discounts) sorted by the specified comparer in the specified zero-indexed range.
public IEnumerable<Discount> GetProductDiscounts(int rangeStart, int rangeEnd, SortBy sortBy, SortDirection sortDirection, ref int totalCount)

Parameters

rangeStart int
The start index.
rangeEnd int
The end index.
sortBy SortBy
The sort by.
sortDirection SortDirection
The sort direction.
totalCount int
Returns the total count of discounts.

Returns

IEnumerable<Discount>
The IEnumerable<T>.

GetProductDiscounts(int, int, SortBy, SortDirection, string, ref int)

Gets the product discounts (orderline discounts) sorted by the specified comparer in the specified zero-indexed range.
public IEnumerable<Discount> GetProductDiscounts(int rangeStart, int rangeEnd, SortBy sortBy, SortDirection sortDirection, string shopId, ref int totalCount)

Parameters

rangeStart int
The start index.
rangeEnd int
The end index.
sortBy SortBy
The sort by.
sortDirection SortDirection
The sort direction.
shopId string
The shop ID.
totalCount int
Returns the total count of discounts.

Returns

IEnumerable<Discount>
The IEnumerable<T>.

Save(Discount)

Saves the discount and its translations.
public Discount Save(Discount discount)

Parameters

discount Discount
The discount.

Returns

Discount
The discount after saving.

SaveDiscountTranslation(int, DiscountTranslation)

Saves the discount translation.
[Obsolete("Use discount.Translations instead.")]
public DiscountTranslation SaveDiscountTranslation(int discountId, DiscountTranslation translation)

Parameters

discountId int
The discount ID.
translation DiscountTranslation
The translation.

Returns

DiscountTranslation
To top