コード例 #1
0
        public void GetContentItemVariantUpsertModel_ReturnsExpected()
        {
            var model    = GetTestModel();
            var expected = ToDynamic(model);
            var actual   = _modelProvider.GetContentItemVariantUpsertModel(model).Elements;

            AssertElements(expected, actual);
        }
コード例 #2
0
        /// <summary>
        /// Inserts or updates given content item variant.
        /// </summary>
        /// <typeparam name="T">Type of the content item elements</typeparam>
        /// <param name="identifier">The identifier of the content item variant.</param>
        /// <param name="variantElements">Represents inserted or updated  strongly typed content item variant elements.</param>
        /// <returns>The <see cref="ContentItemVariantModel{T}"/> instance that represents inserted or updated content item variant.</returns>
        public async Task <ContentItemVariantModel <T> > UpsertContentItemVariantAsync <T>(ContentItemVariantIdentifier identifier, T variantElements) where T : new()
        {
            if (identifier == null)
            {
                throw new ArgumentNullException(nameof(identifier));
            }

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

            var endpointUrl        = _urlBuilder.BuildVariantsUrl(identifier);
            var variantUpsertModel = _modelProvider.GetContentItemVariantUpsertModel(variantElements);
            var response           = await _actionInvoker.InvokeMethodAsync <ContentItemVariantUpsertModel, ContentItemVariantModel>(endpointUrl, HttpMethod.Put, variantUpsertModel);

            return(_modelProvider.GetContentItemVariantModel <T>(response));
        }