Example #1
0
        /// <summary>
        /// Gets the total price of an Item Cache (basket or wish list).
        /// </summary>
        /// <param name="itemCache">
        /// The item cache.
        /// </param>
        /// <typeparam name="TLineItemModel">
        /// The type of the line item
        /// </typeparam>
        /// <returns>
        /// The total price.
        /// </returns>
        public static decimal Total <TLineItemModel>(this IItemCacheModel <TLineItemModel> itemCache)
            where TLineItemModel : class, ILineItemModel, new()
        {
            var subTotal  = itemCache.Items.Where(x => x.LineItemType != LineItemType.Discount).Sum(x => x.Total());
            var discounts = itemCache.Items.Where(x => x.LineItemType == LineItemType.Discount).Sum(x => x.Total());

            return(subTotal - discounts);
        }
Example #2
0
 /// <summary>
 /// Gets the total price of an Item Cache (basket or wish list).
 /// </summary>
 /// <param name="itemCache">
 /// The item cache.
 /// </param>
 /// <typeparam name="TLineItemModel">
 /// The type of the line item
 /// </typeparam>
 /// <returns>
 /// The total price.
 /// </returns>
 public static decimal Total <TLineItemModel>(this IItemCacheModel <TLineItemModel> itemCache)
     where TLineItemModel : class, ILineItemModel, new()
 {
     return(itemCache.Items.Sum(x => x.Total()));
 }