コード例 #1
0
        public async Task UpdateCartDiscountSetValidFrom()
        {
            await WithUpdateableCartDiscount(client, async cartDiscount =>
            {
                var newValidFrom  = cartDiscount.ValidFrom.AddDays(1);
                var updateActions = new List <UpdateAction <CartDiscount> >();
                var action        = new SetValidFromUpdateAction {
                    ValidFrom = newValidFrom
                };
                updateActions.Add(action);

                var updatedCartDiscount = await client
                                          .ExecuteAsync(new UpdateByIdCommand <CartDiscount>(cartDiscount, updateActions));
                Assert.Equal(newValidFrom, updatedCartDiscount.ValidFrom);
                return(updatedCartDiscount);
            });
        }
コード例 #2
0
        public async Task UpdateDiscountCodeSetValidFrom()
        {
            await WithUpdateableDiscountCode(client, async discountCode =>
            {
                var newValidFrom  = discountCode.ValidFrom.AddDays(1);
                var updateActions = new List <UpdateAction <DiscountCode> >();
                var action        = new SetValidFromUpdateAction {
                    ValidFrom = newValidFrom
                };
                updateActions.Add(action);

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

                Assert.Equal(newValidFrom, updatedDiscountCode.ValidFrom);
                return(updatedDiscountCode);
            });
        }
コード例 #3
0
        public async Task UpdateProductDiscountSetValidFrom()
        {
            await WithUpdateableProductDiscount(client,
                                                DefaultProductDiscountDraft,
                                                async productDiscount =>
            {
                var validFrom = DateTime.Today.AddDays(5).ToUniversalTime();
                var action    = new SetValidFromUpdateAction
                {
                    ValidFrom = validFrom
                };

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

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

            List <UpdateAction <ProductDiscount> > updateActions = new List <UpdateAction <ProductDiscount> >();
            SetValidFromUpdateAction setValidFromUpdateAction    = new SetValidFromUpdateAction()
            {
                ValidFrom = DateTime.Today.AddDays(5)
            };

            updateActions.Add(setValidFromUpdateAction);

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

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