コード例 #1
0
        private int GetProductIterations(FreeItemsDealPrice priceObject)
        {
            int productIterations = (int)Math.Floor(
                (decimal)priceObject.ItemPrice.AmoundOfItems /
                (priceObject.ItemPrice.ItemInterval + priceObject.AmountOfFreeItems)
                );

            return(productIterations);
        }
コード例 #2
0
        /// <summary>
        /// Calculates the prices for the store
        /// </summary>
        /// <param name="priceObject"></param>
        /// <returns></returns>
        public decimal CalculatePriceForFreeItemsDeal(FreeItemsDealPrice priceObject)
        {
            //the amount of times the buyer qualifies for the free items
            var productIterations = GetProductIterations(priceObject);

            //the amount of free items the user will get
            int amountOfFreeItems = productIterations * priceObject.AmountOfFreeItems;

            //subtract the free items from the item count and calculate the price
            return((priceObject.ItemPrice.AmoundOfItems - amountOfFreeItems) * priceObject.ItemPrice.PricePerItem);
        }