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
intKey to reset
Delete(int)
Deletes the discount and its translations.
public void Delete(int discountId)
Parameters
discountId
intThe discount ID.
GetActiveOrderAndOrderInclusiveDiscounts()
Gets active order and order inclusive discounts.
public IEnumerable<Discount> GetActiveOrderAndOrderInclusiveDiscounts()
Returns
GetActiveOrderInclusiveDiscounts()
Gets active order inclusive discounts.
public IEnumerable<Discount> GetActiveOrderInclusiveDiscounts()
Returns
GetActiveOrderLineDiscounts()
Gets active order line discounts.
public IEnumerable<Discount> GetActiveOrderLineDiscounts()
Returns
GetDiscount(int)
Gets the discount.
public Discount GetDiscount(int discountId)
Parameters
discountId
int
Returns
GetDiscountGiven(Discount, Currency)
Gets the discount given for a discount in the specified currency.
public double GetDiscountGiven(Discount discount, Currency currency)
Parameters
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
DateTimeThe start date.
Returns
GetDiscounts()
Gets all discounts.
public IEnumerable<Discount> GetDiscounts()
Returns
- IEnumerable<Discount>
The collection of the Discount.
GetDiscounts(Group, bool)
public IEnumerable<Discount> GetDiscounts(Group group, bool excludingDiscount)
Parameters
Returns
GetDiscounts(Product, bool)
public IEnumerable<Discount> GetDiscounts(Product product, bool excludingDiscount)
Parameters
Returns
GetDiscounts(IEnumerable<int>)
public virtual IEnumerable<Discount> GetDiscounts(IEnumerable<int> discountIds)
Parameters
discountIds
IEnumerable<int>
Returns
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
intThe start index.
rangeEnd
intThe end index.
sortBy
SortByThe sort by.
sortDirection
SortDirectionThe sort direction.
assignableFromProducts
boolThe aasignable from products.
shops
IEnumerable<Shop>The shops.
totalCount
intReturns the total count of discounts.
Returns
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
intThe start index.
rangeEnd
intThe end index.
sortBy
SortByThe sort by.
sortDirection
SortDirectionThe sort direction.
totalCount
intReturns the total count of discounts.
Returns
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
intThe start index.
rangeEnd
intThe end index.
sortBy
SortByThe sort by.
sortDirection
SortDirectionThe sort direction.
shopId
stringThe shop ID.
totalCount
intReturns the total count of discounts.
Returns
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
GetGroupDiscounts(Product, bool)
public IEnumerable<Discount> GetGroupDiscounts(Product product, bool excludingDiscount)
Parameters
Returns
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
OrderThe order where you wish to apply the discount.
points
doubleThe number of loyalty points to calculate their cost.
Returns
GetOrderCountByEmail(Discount, string)
public virtual int GetOrderCountByEmail(Discount discount, string email)
Parameters
Returns
GetOrderCountByUserId(Discount, int)
public virtual int GetOrderCountByUserId(Discount discount, int userid)
Parameters
Returns
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
intThe start index.
rangeEnd
intThe end index.
sortBy
SortByThe sort by.
sortDirection
SortDirectionThe sort direction.
totalCount
intReturns the total count of discounts.
Returns
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
intThe start index.
rangeEnd
intThe end index.
sortBy
SortByThe sort by.
sortDirection
SortDirectionThe sort direction.
shopId
stringThe shop ID.
totalCount
intReturns the total count of discounts.
Returns
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
intThe start index.
rangeEnd
intThe end index.
sortBy
SortByThe sort by.
sortDirection
SortDirectionThe sort direction.
totalCount
intReturns the total count of discounts.
Returns
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
intThe start index.
rangeEnd
intThe end index.
sortBy
SortByThe sort by.
sortDirection
SortDirectionThe sort direction.
shopId
stringThe shop ID.
totalCount
intReturns the total count of discounts.
Returns
Save(Discount)
Saves the discount and its translations.
public Discount Save(Discount discount)
Parameters
discount
DiscountThe discount.
Returns
- Discount
The discount after saving.