Exemplo n.º 1
0
        public void Calculate_ShouldReturnDiscountResult_WithCorrectProductsAndModel()
        {
            // Arrange
            IQuantityDiscountCalculator timespanDiscountCalculator = new QuantityDiscountCalculator();
            List <Product> products = new List <Product>()
            {
                new Product()
                {
                    Id = 1, Name = "Beans", PluralName = "Beans", Price = 0.65m
                },
                new Product()
                {
                    Id = 2, Name = "Bread", PluralName = "Breads", Price = 0.8m
                },
                new Product()
                {
                    Id = 3, Name = "Milk", PluralName = "Milk", Price = 1.3m
                },
                new Product()
                {
                    Id = 4, Name = "Apple", PluralName = "Apples", Price = 1.0m
                },
            };
            QuantityDiscount quantityDiscount = new QuantityDiscount()
            {
                Id                 = 1,
                BuyingProduct      = products[0],
                Quantity           = 2,
                DiscountedProduct  = products[1],
                DiscountPercentage = 0.5f,
                IsActive           = true
            };
            IEnumerable <BasketItem> items = new List <BasketItem>()
            {
                new BasketItem()
                {
                    Product = new BasketItemProduct()
                    {
                        Id = 1, Name = "Beans", PluralName = "Beans", Price = 0.65m
                    },
                    Quantity = 2
                },
                new BasketItem()
                {
                    Product = new BasketItemProduct()
                    {
                        Id = 2, Name = "Bread", PluralName = "Breads", Price = 0.8m
                    },
                    Quantity = 1
                },
            };

            // Act
            DiscountResult discountResult = timespanDiscountCalculator.Calculate(items, quantityDiscount);

            // Assert
            Assert.Equal(0.5, discountResult.DiscountPercentage);
            Assert.Equal(0.40m, discountResult.DiscountedPrice);
            Assert.Equal("Breads", discountResult.ProductPluralName);
        }
Exemplo n.º 2
0
 public DiscountData(string productId, string discountName, int discountCondition, DiscountResult discountResult)
 {
     ProductId         = productId;
     Name              = discountName;
     DiscountCondition = discountCondition;
     DiscountResult    = discountResult;
 }
Exemplo n.º 3
0
        public void Calculate_ShouldReturnDiscountResult_WithCorrectProductsAndModel()
        {
            // Arrange
            Mock <IDateTimeUtil> mockDateTimeUtil = new Mock <IDateTimeUtil>();

            mockDateTimeUtil.Setup(x => x.Now()).Returns(new DateTime(2020, 10, 15));
            ITimespanDiscountCalculator timespanDiscountCalculator = new TimespanDiscountCalculator(mockDateTimeUtil.Object);
            List <Product> products = new List <Product>()
            {
                new Product()
                {
                    Id = 1, Name = "Beans", PluralName = "Beans", Price = 0.65m
                },
                new Product()
                {
                    Id = 2, Name = "Bread", PluralName = "Breads", Price = 0.8m
                },
                new Product()
                {
                    Id = 3, Name = "Milk", PluralName = "Milk", Price = 1.3m
                },
                new Product()
                {
                    Id = 4, Name = "Apple", PluralName = "Apples", Price = 1.0m
                },
            };
            TimespanDiscount timespanDiscount = new TimespanDiscount()
            {
                Id                 = 1,
                BuyingProduct      = products[3],
                From               = new DateTime(2020, 10, 10),
                To                 = new DateTime(2020, 10, 20),
                DiscountedProduct  = products[3],
                DiscountPercentage = 0.1f,
                IsActive           = true
            };
            IEnumerable <BasketItem> items = new List <BasketItem>()
            {
                new BasketItem()
                {
                    Product = new BasketItemProduct()
                    {
                        Id = 4, Name = "Apple", PluralName = "Apples", Price = 1.0m
                    },
                    Quantity = 1
                },
            };

            // Act
            DiscountResult discountResult = timespanDiscountCalculator.Calculate(items, timespanDiscount);

            // Assert
            Assert.Equal(0.1f, discountResult.DiscountPercentage);
            Assert.Equal(0.10m, discountResult.DiscountedPrice);
            Assert.Equal("Apples", discountResult.ProductPluralName);
        }
Exemplo n.º 4
0
        public void ApplyDiscountTest()
        {
            StockKeepingUnit temp = new StockKeepingUnit("Test1", 1.5);
            BuyItemsLessPercentageDiscountUnit target = new BuyItemsLessPercentageDiscountUnit("Test 1 discount", temp, 1, 10.0); // TODO: Initialize to an appropriate value
            StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp });                               // TODO: Initialize to an appropriate value

            double         expected = 0.3F;                                                                                       // TODO: Initialize to an appropriate value
            DiscountResult actual   = target.ApplyDiscount(items);

            Assert.IsTrue(System.Math.Round(expected, 2) == System.Math.Round(actual.Discount, 2));
        }
        public void ApplyDiscountTest2()
        {
            StockKeepingUnit temp = new StockKeepingUnit("Test1", 1.5);
            BuyItemsGetOneFreeDiscountUnit target = new BuyItemsGetOneFreeDiscountUnit("Test 1 discount", temp, 2); // TODO: Initialize to an appropriate value
            StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp, temp });           // TODO: Initialize to an appropriate value

            double         expected = 1.5F;                                                                         // TODO: Initialize to an appropriate value
            DiscountResult actual   = target.ApplyDiscount(items);

            Assert.AreEqual <double>(expected, actual.Discount);
        }
Exemplo n.º 6
0
        public void ApplyDiscountTest()
        {
            StockKeepingUnit temp  = new StockKeepingUnit("Test1", 1.5F);
            StockKeepingUnit temp2 = new StockKeepingUnit("Test2", 5.0F);
            BuyItemsGetPercentageFromItemDiscountUnit target = new BuyItemsGetPercentageFromItemDiscountUnit("Test 1 discount", temp, temp2, 2, 50.0); // TODO: Initialize to an appropriate value
            StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp, temp2 });                                             // TODO: Initialize to an appropriate value

            double         expected = 2.5F;                                                                                                            // TODO: Initialize to an appropriate value
            DiscountResult actual   = target.ApplyDiscount(items);

            Assert.IsTrue(System.Math.Round(expected, 2) == System.Math.Round(actual.Discount, 2));
        }
Exemplo n.º 7
0
        public void ApplyDiscountTest2()
        {
            StockKeepingUnit temp = new StockKeepingUnit("Test1", 1.5);
            BuyItemsLessPercentageDiscountUnit target = new BuyItemsLessPercentageDiscountUnit("Test 1 discount", temp, 2, 20.00F); // TODO: Initialize to an appropriate value
            StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp, temp });                           // TODO: Initialize to an appropriate value

            double         expected = 0.3;                                                                                          // TODO: Initialize to an appropriate value
            DiscountResult actual   = target.ApplyDiscount(items);

            //Even though these were actually equal, precision screwed up the test.... *sigh*
            Assert.IsTrue(System.Math.Round(expected, 2) == System.Math.Round(actual.Discount, 2));
        }
Exemplo n.º 8
0
        public void DiscountResultConstructorTest()
        {
            string         description = "test"; // TODO: Initialize to an appropriate value
            double         discount    = 20.5F;  // TODO: Initialize to an appropriate value
            bool           applied     = true;   // TODO: Initialize to an appropriate value
            DiscountResult target      = new DiscountResult(description, discount, applied);

            Assert.IsNotNull(target);
            Assert.AreEqual(description, target.Description);
            Assert.AreEqual(discount, target.Discount);
            Assert.AreEqual(applied, target.Applied);
        }
        public void ApplyDiscountTest3()
        {
            StockKeepingUnit temp = new StockKeepingUnit("Test1", 1.5);
            BuyItemsGetOneFreeDiscountUnit target = new BuyItemsGetOneFreeDiscountUnit("Test 1 discount", temp, 2); // TODO: Initialize to an appropriate value

            //this should match 2 offers, should ignore the extra item
            StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp, temp, temp, temp, temp, temp }); // TODO: Initialize to an appropriate value

            double         expected = 3.0F;                                                                                       // TODO: Initialize to an appropriate value
            DiscountResult actual   = target.ApplyDiscount(items);

            Assert.AreEqual <double>(expected, actual.Discount);
        }
Exemplo n.º 10
0
        public void ApplyDiscountTest2()
        {
            StockKeepingUnit temp  = new StockKeepingUnit("Test1", 1.5F);
            StockKeepingUnit temp2 = new StockKeepingUnit("Test2", 5.0F);
            BuyItemsGetPercentageFromItemDiscountUnit target = new BuyItemsGetPercentageFromItemDiscountUnit("Test 1 discount", temp, temp2, 2, 50.0); // TODO: Initialize to an appropriate value
            StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp, temp2, temp, temp, temp2, temp2 });                   // TODO: Initialize to an appropriate value

            //there should be 2 discounts on Test 2 (50% or 5, so 2 x 2.5) and the extra Test2 should be ignored.
            double         expected = 5.0F; // TODO: Initialize to an appropriate value
            DiscountResult actual   = target.ApplyDiscount(items);

            Assert.IsTrue(System.Math.Round(expected, 2) == System.Math.Round(actual.Discount, 2), string.Format("L: {0} R: {1}", expected, actual.Discount));
        }
Exemplo n.º 11
0
        private void GetQuantityDiscounts(IEnumerable <BasketItem> items, List <DiscountResult> discounts)
        {
            IEnumerable <QuantityDiscount> quantityDiscounts = this.dbContext.QuantityDiscounts.Where(d => d.IsActive);

            foreach (QuantityDiscount quantityDiscount in quantityDiscounts)
            {
                DiscountResult discountResult = this.quantityDiscountCalculator.Calculate(items, quantityDiscount);
                if (discountResult != null)
                {
                    discounts.Add(discountResult);
                }
            }
        }
Exemplo n.º 12
0
        private void GetTimespanDiscounts(IEnumerable <BasketItem> items, List <DiscountResult> discounts)
        {
            IEnumerable <TimespanDiscount> timeSpanDiscounts = this.dbContext.TimeSpanDiscounts.Where(d => d.IsActive);

            foreach (TimespanDiscount timeSpanDiscount in timeSpanDiscounts)
            {
                DiscountResult discountResult = this.timeSpanDiscountCalculator.Calculate(items, timeSpanDiscount);
                if (discountResult != null)
                {
                    discounts.Add(discountResult);
                }
            }
        }
Exemplo n.º 13
0
        public async Task ShouldReturnDiscountCreatedWithValuesAsync()
        {
            //Act

            DiscountResult result = await discount.CreateDiscountAsync(discountRequest);


            //Asset
            Assert.NotNull(result);
            Assert.Equal(discountRequest.Descripcion, result.Descripcion);
            Assert.Equal(discountRequest.Porcentaje, result.Porcentaje);
            Assert.Equal(discountRequest.Vigencia, result.Vigencia);
        }
        public void GetDiscounts_ShouldReturnOnlyQuantityDiscount_WithCorrectProductsForQuantity()
        {
            // Arrange
            Mock <ITimespanDiscountCalculator> mockTimespanDiscountCalculator = new Mock <ITimespanDiscountCalculator>();

            mockTimespanDiscountCalculator.Setup(x => x.Calculate(It.IsAny <IEnumerable <BasketItem> >(), It.IsAny <TimespanDiscount>())).Returns <DiscountResult>(null);

            DiscountResult quantityDiscountResult = new DiscountResult()
            {
                DiscountedPrice    = 0.4m,
                DiscountPercentage = 50,
                ProductPluralName  = "Beans",
            };
            Mock <IQuantityDiscountCalculator> mockQuantityDiscountCalculator = new Mock <IQuantityDiscountCalculator>();

            mockQuantityDiscountCalculator.Setup(x => x.Calculate(It.IsAny <IEnumerable <BasketItem> >(), It.IsAny <QuantityDiscount>())).Returns(quantityDiscountResult);

            this.discountService = new DiscountService(this.dbContext, mockTimespanDiscountCalculator.Object, mockQuantityDiscountCalculator.Object);

            List <BasketItem> items = new List <BasketItem>()
            {
                new BasketItem()
                {
                    Product = new BasketItemProduct()
                    {
                        Id = 1, Name = "Beans", PluralName = "Beans", Price = 0.65m
                    },
                    Quantity = 2
                },
                new BasketItem()
                {
                    Product = new BasketItemProduct()
                    {
                        Id = 2, Name = "Bread", PluralName = "Breads", Price = 0.8m
                    },
                    Quantity = 1
                },
            };

            // Act
            IEnumerable <DiscountResult> discounts = this.discountService.GetDiscounts(items);

            // Assert
            Assert.Single(discounts);
            Assert.Collection(discounts, discount =>
            {
                Assert.Equal(quantityDiscountResult.DiscountedPrice, discount.DiscountedPrice);
                Assert.Equal(quantityDiscountResult.DiscountPercentage, discount.DiscountPercentage);
                Assert.Equal(quantityDiscountResult.ProductPluralName, discount.ProductPluralName);
            });
        }
        public void DiscountResultsConstructorTest()
        {
            IEnumerable <DiscountResult> collection = new DiscountResult[] {
                new DiscountResult("test1", 50.0, true),
                new DiscountResult("test2", 50.0, false), //this one should be ignored
                new DiscountResult("test3", 100.0, true),
                new DiscountResult("test4", 25.0, true),
                new DiscountResult("test5", 75.0, true)
            }; // TODO: Initialize to an appropriate value

            DiscountResults target = new DiscountResults(collection);

            Assert.IsNotNull(target);
            Assert.AreEqual(target.Count, 5);
        }
        public DiscountResult CalculateDiscountForItems(List<Item> items)
        {
            var result = new DiscountResult {DiscountAwarded = 0, DiscountedItems = new List<Item>()};

            const int multipleNeededForReward = 3;
            const decimal discountReward = 20;
            const string itemForDiscount = "A";

            var itemAmountInCart = items.Count(i => i.Name == itemForDiscount);
            var multipleInCart = Math.Floor(itemAmountInCart / (decimal)multipleNeededForReward);

            result.DiscountAwarded = discountReward * multipleInCart;

            return result;
        }
Exemplo n.º 17
0
        public async Task ShouldReturnExpectedResultoCodeAsync(DiscountResultCode expectedResultCode, bool isProductAvailable)
        {
            //Arrange

            if (!isProductAvailable)
            {
                _availableproduct.Clear();
            }

            _productRepositoryMock.Setup(x => x.GetById(discountRequest.ProductDescription)).ReturnsAsync(_availableproduct.FirstOrDefault());

            //Act
            DiscountResult result = await discount.CreateDiscountAsync(discountRequest);

            //Assert
            Assert.Equal(expectedResultCode, result.Code);
        }
Exemplo n.º 18
0
        public DiscountResult GetCartDiscount(ShoppingCartItemListDTO shoppingCartItemListDTO)
        {
            CartRepository cartRepository = new CartRepository();
            var            currentUser    = ClaimsPrincipal.Current.Identity.Name;
            UserService    userService    = new UserService();

            if (shoppingCartItemListDTO != null && shoppingCartItemListDTO.shoppingCartDTOList != null && shoppingCartItemListDTO.shoppingCartDTOList.Count > 0 &&
                currentUser != null)
            {
                var user = userService.GetUser(currentUser);
                var shoppingCartItemList = GetShoppingCartItemForUser(user.UserId);

                //Get Discount details.
                DiscountResult discountDetails = _shoppingCartRepository.GetDiscountDetails(shoppingCartItemListDTO.couponCode);
            }
            return(null);
        }
Exemplo n.º 19
0
        public DiscountResult Calculate(IEnumerable <BasketItem> items, QuantityDiscount model)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            BasketItem buyingProduct = items.FirstOrDefault(p => p.Product.Id == model.BuyingProduct.Id);

            if (buyingProduct == null)
            {
                return(null);
            }

            BasketItem productForDiscount = items.FirstOrDefault(p => p.Product.Id == model.DiscountedProduct.Id);

            if (productForDiscount == null)
            {
                return(null);
            }

            int quantity          = buyingProduct.Quantity / model.Quantity;
            int numberOfDiscounts = quantity > productForDiscount.Quantity ? productForDiscount.Quantity : quantity;

            if (numberOfDiscounts == 0)
            {
                return(null);
            }

            decimal currentPrice    = productForDiscount.Product.Price;
            decimal discountedPrice = (currentPrice * (decimal)model.DiscountPercentage) * numberOfDiscounts;

            DiscountResult result = new DiscountResult();

            result.DiscountedPrice    = discountedPrice;
            result.ProductPluralName  = productForDiscount.Product.PluralName;
            result.DiscountPercentage = model.DiscountPercentage;

            return(result);
        }
Exemplo n.º 20
0
        public DiscountResult Calculate(IEnumerable <BasketItem> items, TimespanDiscount model)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            DateTime currentDate = this.dateTimeUtil.Now();

            if (currentDate < model.From || currentDate > model.To)
            {
                return(null);
            }

            BasketItem buyingProduct = items.FirstOrDefault(p => p.Product.Id == model.BuyingProduct.Id);

            if (buyingProduct == null)
            {
                return(null);
            }

            BasketItem productForDiscount = items.FirstOrDefault(p => p.Product.Id == model.DiscountedProduct.Id);

            if (productForDiscount == null)
            {
                return(null);
            }

            decimal currentPrice    = productForDiscount.Product.Price;
            decimal discountedPrice = (currentPrice * (decimal)model.DiscountPercentage) * productForDiscount.Quantity;

            DiscountResult result = new DiscountResult();

            result.DiscountedPrice    = discountedPrice;
            result.ProductPluralName  = productForDiscount.Product.PluralName;
            result.DiscountPercentage = model.DiscountPercentage;

            return(result);
        }
Exemplo n.º 21
0
        public CheckoutState Apply(CheckoutState checkoutState)
        {
            var applicableItems = GetApplicableItems(checkoutState).ToArray();

            if (!applicableItems.Any())
            {
                return(ToNotAppliedCheckoutState(checkoutState, GetNoApplicableProductsMessage()));
            }

            var leftToSpend = AmountRequiredToPassThreshold(checkoutState.DiscountableItemsTotal);

            if (leftToSpend > 0)
            {
                return(ToNotAppliedCheckoutState(checkoutState, GetThresholdNotReachedMessage(leftToSpend)));
            }

            var currentSpendOnApplicableItems = CurrentSpendOnApplicableItems(applicableItems);
            var discountToApply = CalculateDiscountToApply(currentSpendOnApplicableItems);
            var newStateTotal   = checkoutState.CurrentTotal - discountToApply;

            return(checkoutState.ToNewState(newStateTotal, DiscountResult.CreateApplied(_id)));
        }
        public void BuyItemsGetOneFreeDiscountUnitConstructorTest()
        {
            string           name    = "Test1";                             // TODO: Initialize to an appropriate value
            StockKeepingUnit target1 = new StockKeepingUnit("Test1", 1.5);; // TODO: Initialize to an appropriate value
            int targetCount          = 1;                                   // TODO: Initialize to an appropriate value
            BuyItemsGetOneFreeDiscountUnit target = new BuyItemsGetOneFreeDiscountUnit(name, target1, targetCount);

            Assert.IsNotNull(target, "Valid instance");

            double         expected = 1.5F; // TODO: Initialize to an appropriate value
            DiscountResult actual   = target.ApplyDiscount(new StockKeepingUnits()
            {
                target1, target1
            });

            Assert.AreEqual <double>(expected, actual.Discount);

            Assert.IsNotNull(target);
            Assert.AreEqual(name, target.Name);
            Assert.AreEqual(name, target.Name);
            Assert.AreEqual(targetCount, target.TargetLevel);
        }
Exemplo n.º 23
0
        private CheckoutState ToNotAppliedCheckoutState(CheckoutState checkoutState, string message)
        {
            var notAppliedResult = DiscountResult.CreateNotApplied(_id, message);

            return(checkoutState.ToNewState(checkoutState.CurrentTotal, notAppliedResult));
        }
Exemplo n.º 24
0
 public CheckoutState ToNewState(decimal newTotal, DiscountResult discountResult)
 {
     return(new CheckoutState(Items, newTotal, DiscountResults.Append(discountResult).ToArray()));
 }
        public async Task <DiscountResult> GetDiscountResult(int id, string employeeFirstName, string employeeLastName, ICollection <Dependent> dependents)
        {
            var discountCriteria = await _context.DiscountCriterias.FirstAsync();

            var result = new DiscountResult();

            result.Dependents = new List <Dependent>();

            if (employeeFirstName.StartsWith(discountCriteria.DiscountQualifier) || employeeLastName.StartsWith(discountCriteria.DiscountQualifier))
            {
                result.TotalYearlyBenefitCost = discountCriteria.BaseEmployeeBenefitCost - (discountCriteria.BaseEmployeeBenefitCost * discountCriteria.DiscountPerctentageRate);
                result.TotalDiscount         += discountCriteria.BaseEmployeeBenefitCost * discountCriteria.DiscountPerctentageRate;
                result.isDiscounted           = true;
            }
            else
            {
                result.TotalYearlyBenefitCost = discountCriteria.BaseEmployeeBenefitCost;
                result.TotalDiscount          = 0.00m;
                result.isDiscounted           = false;
            }

            foreach (var dependent in dependents)
            {
                if (dependent.FirstName.StartsWith(discountCriteria.DiscountQualifier) || dependent.LastName.StartsWith(discountCriteria.DiscountQualifier))
                {
                    result.TotalYearlyBenefitCost    += (discountCriteria.BaseDependentBenefitCost - (discountCriteria.BaseDependentBenefitCost * discountCriteria.DiscountPerctentageRate));
                    result.TotalDependentBenefitCost += (discountCriteria.BaseDependentBenefitCost - (discountCriteria.BaseDependentBenefitCost * discountCriteria.DiscountPerctentageRate));
                    result.TotalDiscount             += discountCriteria.BaseDependentBenefitCost * discountCriteria.DiscountPerctentageRate;
                    result.isDiscounted = true;

                    var dependentData = new Dependent
                    {
                        DependentId         = dependent.DependentId,
                        EmployeeId          = dependent.EmployeeId,
                        FirstName           = dependent.FirstName,
                        LastName            = dependent.LastName,
                        BenefitCostIncurred = (discountCriteria.BaseDependentBenefitCost - (discountCriteria.BaseDependentBenefitCost * discountCriteria.DiscountPerctentageRate))
                    };
                    result.Dependents.Add(dependentData);
                }
                else
                {
                    result.TotalYearlyBenefitCost    += discountCriteria.BaseDependentBenefitCost;
                    result.TotalDependentBenefitCost += discountCriteria.BaseDependentBenefitCost;

                    var dependentData = new Dependent
                    {
                        DependentId         = dependent.DependentId,
                        EmployeeId          = dependent.EmployeeId,
                        FirstName           = dependent.FirstName,
                        LastName            = dependent.LastName,
                        BenefitCostIncurred = discountCriteria.BaseDependentBenefitCost
                    };
                    result.Dependents.Add(dependentData);
                }
            }

            result.TotalCountOfDependents                 = dependents.Count;
            result.CostPerPayCheck                        = result.TotalYearlyBenefitCost / 26;
            result.EmployeeFirstName                      = employeeFirstName;
            result.EmployeeLastName                       = employeeLastName;
            result.EmployeeId                             = id;
            result.TotalChecksDispursedAnnually           = discountCriteria.TotalYearlyCheckDisbursment;
            result.TotalEmployeeOnlyBenefitCost           = discountCriteria.BaseEmployeeBenefitCost;
            result.YearlyDependentBaseBenefitCost         = discountCriteria.BaseDependentBenefitCost;
            result.YearlyGrossSalary                      = discountCriteria.EmployeeBiWeeklyBasePay * 26;
            result.YearlyGrossSalaryAfterBenefitDeduction = result.YearlyGrossSalary - result.TotalYearlyBenefitCost;


            return(result);
        }
Exemplo n.º 26
0
        private static void FillDiscount(string productId, string discountName, int discountCondition, DiscountResult discountResult)
        {
            // * Notes:
            //  productId - discount for what product,
            //  discountCondition - e.x. Buy "2" or more.... or Buy "100" or more... and ect...
            //  discountResult - discountResult.Percents - discount by percents, discountResult.ProductId - discount for what product, (discountResult.ProductId == Empty - for whole basket)
            if ((discountCondition == 0 || discountCondition < 0) || (discountResult.Percents == 0 || discountResult.Percents < 0))
            {
                throw new Exception();
            }

            DiscountDatas.Add(new DiscountData(productId, discountName, discountCondition, discountResult));
        }