/// <summary> /// Get the best discount in the list of discounts by page id /// </summary> public void TryGetBestDiscount(int pageId, out CatalogueDiscountData catalogueDiscountData) { catalogueDiscountData = null; var discounts = Discounts.Where(x => x.PageId == pageId && (x.ExpireDate > DateTime.Now || x.ExpireDate == null)).ToList(); if (!discounts.Any()) { return; } catalogueDiscountData = discounts .Where(x => x.DiscountBatchSize > 0 && x.DiscountAmountPerBatch > 0) .OrderByDescending(x => x.DiscountAmountPerBatch / x.DiscountBatchSize) .FirstOrDefault(); }
public CatalogueItemDiscountComposer(CatalogueDiscountData discount) { this.discount = discount; }