Example #1
0
        public async Task UpdateCartDiscountSetValidUntil()
        {
            await WithUpdateableCartDiscount(client, async cartDiscount =>
            {
                var newValidUntil = cartDiscount.ValidUntil.AddDays(1);
                var updateActions = new List <UpdateAction <CartDiscount> >();
                var action        = new SetValidUntilUpdateAction {
                    ValidUntil = newValidUntil
                };
                updateActions.Add(action);

                var updatedCartDiscount = await client
                                          .ExecuteAsync(new UpdateByIdCommand <CartDiscount>(cartDiscount, updateActions));
                Assert.Equal(newValidUntil, updatedCartDiscount.ValidUntil);
                return(updatedCartDiscount);
            });
        }
Example #2
0
        public async Task UpdateDiscountCodeSetValidUntil()
        {
            await WithUpdateableDiscountCode(client, async discountCode =>
            {
                var newValidUntil = discountCode.ValidUntil.AddDays(1);
                var updateActions = new List <UpdateAction <DiscountCode> >();
                var action        = new SetValidUntilUpdateAction {
                    ValidUntil = newValidUntil
                };
                updateActions.Add(action);

                var updatedDiscountCode = await client
                                          .ExecuteAsync(new UpdateByIdCommand <DiscountCode>(discountCode, updateActions));

                Assert.Equal(newValidUntil, updatedDiscountCode.ValidUntil);
                return(updatedDiscountCode);
            });
        }
Example #3
0
        public async Task UpdateProductDiscountSetValidUntil()
        {
            await WithUpdateableProductDiscount(client,
                                                DefaultProductDiscountDraft,
                                                async productDiscount =>
            {
                var validUntil = DateTime.Today.AddMonths(5).ToUniversalTime();
                var action     = new SetValidUntilUpdateAction
                {
                    ValidUntil = validUntil
                };

                var updatedProductDiscount = await client
                                             .ExecuteAsync(productDiscount.UpdateById(actions => actions.AddUpdate(action)));

                Assert.Equal(validUntil, updatedProductDiscount.ValidUntil);
                return(updatedProductDiscount);
            });
        }
        public void UpdateProductDiscountByIdSetValidUntil()
        {
            IClient         commerceToolsClient = this.productDiscountFixture.GetService <IClient>();
            ProductDiscount productDiscount     = this.productDiscountFixture.CreateProductDiscount();

            List <UpdateAction <ProductDiscount> > updateActions = new List <UpdateAction <ProductDiscount> >();
            SetValidUntilUpdateAction setValidUntilUpdateAction  = new SetValidUntilUpdateAction()
            {
                ValidUntil = DateTime.Today.AddMonths(2)
            };

            updateActions.Add(setValidUntilUpdateAction);

            ProductDiscount retrievedProductDiscount = commerceToolsClient
                                                       .ExecuteAsync(new UpdateByIdCommand <ProductDiscount>(new Guid(productDiscount.Id), productDiscount.Version, updateActions))
                                                       .Result;

            this.productDiscountFixture.ProductDiscountsToDelete.Add(retrievedProductDiscount);
            Assert.NotEqual(retrievedProductDiscount.ValidUntil, productDiscount.ValidUntil);
        }