private int GetProductIterations(DiscountedDealPrice priceObject) { int productIterations = (int)Math.Floor( (decimal)priceObject.ItemPrice.AmoundOfItems / (priceObject.ItemPrice.ItemInterval) ); return(productIterations); }
/// <summary> /// Calculates the price for a discounted price range deal /// </summary> /// <param name="itemPrice"></param> /// <returns></returns> public decimal CalculatePriceForDiscountDeal(DiscountedDealPrice itemPrice) { var productIterations = GetProductIterations(itemPrice); //The price of the items that is fell out of the price discounted deal decimal outOfRangeItemsPrice = (itemPrice.ItemPrice.AmoundOfItems - (productIterations * itemPrice.ItemPrice.ItemInterval)) * itemPrice.ItemPrice.PricePerItem; //The price of the items that is fell in the price discounted deal decimal inRangeItemsPrice = productIterations * itemPrice.DealPrice; decimal totalPrice = outOfRangeItemsPrice + inRangeItemsPrice; return(totalPrice); }