コード例 #1
0
ファイル: CatalogueManager.cs プロジェクト: Quackster/Kurkku
        /// <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();
        }
コード例 #2
0
 public CatalogueItemDiscountComposer(CatalogueDiscountData discount)
 {
     this.discount = discount;
 }