예제 #1
0
 public async Task <T> GetKontentItem <T>(GetKontentParameters getKontentItemParameters) where T : notnull
 {
     return(await GetDeliveryClient()
            .GetItemAsync <T>(
                getKontentItemParameters.Codename,
                new LanguageParameter(coreContext.Localization)
                ));
 }
예제 #2
0
        public async Task <TransferItem> CreateTransferItem(CreateTransferItemParameters createTransferItemParameters)
        {
            var contentItemResponse = await AddContentItem(createTransferItemParameters);

            var variant = GetNewTransferLanguageVariant(createTransferItemParameters);

            await UpsertLanguageVariant(new UpsertLanguageVariantParameters
            {
                Codename = contentItemResponse.Codename,
                Variant  = variant,
            });

            var getKontentItemParameters = new GetKontentParameters
            {
                Codename = contentItemResponse.Codename
            };

            await PublishLanguageVariant(getKontentItemParameters);

            TransferItem?transferItem = default;

            var retryAttempts = settings.KenticoKontent.PublishLanguageVariantRetry;

            while (retryAttempts > 0)
            {
                try
                {
                    transferItem = await GetKontentItem <TransferItem>(getKontentItemParameters);
                }
                catch { }

                if (transferItem != default)
                {
                    return(transferItem);
                }

                await Task.Delay(1000);

                retryAttempts--;
            }

            throw new Exception($"Published language variant {contentItemResponse.Codename} but could not get it from Delivery.");
        }
예제 #3
0
        public async Task UnpublishLanguageVariant(GetKontentParameters getKontentItemParameters)
        {
            var requestUri = ConfigureClient($"/codename/{getKontentItemParameters.Codename}/variants/codename/{coreContext.Localization}/unpublish");

            await PutAsJsonAsync(requestUri);
        }