Ejemplo n.º 1
0
        /// <summary>
        /// Sets the featured image of the post by first uploading the image on the path and then using its returned imageId
        /// </summary>
        /// <param name="client"></param>
        /// <param name="imagePath"></param>
        /// <returns></returns>
        public async Task <PostBuilder> WithFeaturedImage(WordpressClient client, string imagePath)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (string.IsNullOrEmpty(imagePath))
            {
                throw new ArgumentNullException(nameof(imagePath));
            }

            if (!File.Exists(imagePath))
            {
                throw new FileNotFoundException(nameof(imagePath));
            }

            Responses.Response <Responses.Media> featuredMedia = await client.CreateMediaAsync((builder) => builder.WithHttpBody <MediaBuilder, HttpContent>((media) => media.WithFile(imagePath).Create()).Create());

            FeaturedImageId = featuredMedia.Status ? featuredMedia.Value.Id : 0;
            return(this);
        }
Ejemplo n.º 2
0
 private static bool ConfigNotStoredInConsul(Responses.Response <FileConfiguration> fileConfigFromConsul)
 {
     return(fileConfigFromConsul.Data == null);
 }