Пример #1
0
        public async Task <SiteDesignMetadata> CreateAsync(SiteDesignMetadata siteDesignMetadata, CancellationToken cancellationToken)
        {
            if (siteDesignMetadata == null)
            {
                throw new ArgumentNullException(nameof(siteDesignMetadata));
            }

#pragma warning disable CA1303 // Do not pass literals as localized parameters
#pragma warning disable CA2208 // Instantiate argument exceptions correctly

            if (string.IsNullOrEmpty(siteDesignMetadata.Title))
            {
                throw new ArgumentException(paramName: nameof(siteDesignMetadata.Title), message: "Title must be provided");
            }
            if (siteDesignMetadata.SiteScriptIds == null ||
                siteDesignMetadata.SiteScriptIds.Count == 0)
            {
                throw new ArgumentException(paramName: nameof(siteDesignMetadata.SiteScriptIds), message: "Site Script Id(s) must be provided");
            }
            if (string.IsNullOrEmpty(siteDesignMetadata.WebTemplate))
            {
                throw new ArgumentException(paramName: nameof(siteDesignMetadata.WebTemplate), message: "Web Template must be provided");
            }

#pragma warning restore CA2208 // Instantiate argument exceptions correctly
#pragma warning restore CA1303 // Do not pass literals as localized parameters


            this.AppendSegmentToRequestUrl("Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.CreateSiteDesign");
            this.ContentType = "application/json";
            var requestData = new CreateSiteDesignRequest(siteDesignMetadata);
            var newEntity   = await this.SendAsync <SiteDesignMetadata>(requestData, cancellationToken).ConfigureAwait(false);

            return(newEntity);
        }
Пример #2
0
        public CreateSiteDesignRequest(SiteDesignMetadata siteDesignMetadata)
        {
            if (siteDesignMetadata == null)
            {
                throw new ArgumentNullException(nameof(siteDesignMetadata));
            }

            info = new Info
            {
                Title               = siteDesignMetadata.Title,
                Description         = siteDesignMetadata.Description,
                SiteScriptIds       = siteDesignMetadata.SiteScriptIds,
                WebTemplate         = siteDesignMetadata.WebTemplate,
                PreviewImageUrl     = siteDesignMetadata.PreviewImageUrl,
                PreviewImageAltText = siteDesignMetadata.PreviewImageAltText
            };
        }
Пример #3
0
 public Task <SiteDesignMetadata> CreateAsync(SiteDesignMetadata siteDesignMetadata)
 {
     return(this.CreateAsync(siteDesignMetadata, CancellationToken.None));
 }