/// <summary>
        /// Return Absolute Product Discount Value
        /// </summary>
        /// <returns></returns>
        public static AbsoluteProductDiscountValue GetProductDiscountValueAsAbsolute(int?discountCentAmount = null)
        {
            var money = new Money()
            {
                CurrencyCode = "EUR",
                CentAmount   = discountCentAmount ?? RandomInt(1, 10000)
            };
            var productDiscountValue = new AbsoluteProductDiscountValue()
            {
                Money = new List <Money>()
                {
                    money
                }
            };

            return(productDiscountValue);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Return Absolute Product Discount
        /// </summary>
        /// <returns></returns>
        public AbsoluteProductDiscountValue GetProductDiscountValueAsAbsolute()
        {
            var money = new Money()
            {
                CurrencyCode = "EUR",
                CentAmount   = this.RandomInt(1, 10)
            };
            var productDiscountValue = new AbsoluteProductDiscountValue()
            {
                Money = new List <Money>()
                {
                    money
                }
            };

            return(productDiscountValue);
        }
        private ProductDiscount CreateOrRetrieveProductDiscountOfAbsoluteValue(string productId, int discountCentAmount)
        {
            var money = new Money()
            {
                CurrencyCode = "EUR", CentAmount = discountCentAmount
            };

            var productDiscountValue = new AbsoluteProductDiscountValue()
            {
                Money = new List <Money>()
                {
                    money
                }
            };

            var productDiscount = CreateOrRetrieveByKey <ProductDiscount, ProductDiscountDraft>(client,
                                                                                                KeyProductDiscount,
                                                                                                new ProductDiscountDraft(),
                                                                                                draft =>
            {
                var productDiscountDraft = DefaultProductDiscountDraftWithKey(draft, KeyProductDiscount);

                productDiscountDraft.Value       = productDiscountValue;
                productDiscountDraft.ValidFrom   = DateTime.Today;
                productDiscountDraft.ValidUntil  = DateTime.Today.AddYears(2);
                productDiscountDraft.IsActive    = true;
                productDiscountDraft.Description = new LocalizedString {
                    { "en", DescriptionProductDiscount }
                };
                productDiscountDraft.SetPredicate(product => product.ProductId() == productId);

                return(productDiscountDraft);
            });

            return(productDiscount);
        }