Example #1
0
 /// <summary>
 /// Asynchronously insert the collection of <see cref="Navigation" /> into the system.
 /// </summary>
 /// <typeparam name="T">Type of extended <see cref="Navigation" />.</typeparam>
 /// <param name="navigations">Resource instance.</param>
 /// <returns>Collection of newly created <typeparamref name="T" /> .</returns>
 public virtual Task <BatchResult <T>[]> InsertAsync <T>(T[] navigations) where T : Navigation
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         return(client.PostAsync <T[], BatchResult <T>[]>(client.GetApiUrl(String.Format("{0}/batch", ModuleRelativePath)), navigations));
     }
 }
 /// <summary>
 /// Asynchronously insert the <see cref="CreateArticleComment" /> into the system.
 /// </summary>
 /// <typeparam name="T">Type of extended <see cref="ArticleComment" />.</typeparam>
 /// <param name="comment">The comment.</param>
 /// <returns>Newly created <typeparamref name="T" /> .</returns>
 public virtual Task <T> InsertCommentAsync <T>(T comment)
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         return(client.PostAsync <T>(client.GetApiUrl(ModuleRelativePath), comment));
     }
 }
Example #3
0
 /// <summary>
 /// Asynchronously insert the <see cref="Navigation" /> into the system.
 /// </summary>
 /// <typeparam name="T">Type of extended <see cref="Navigation" />.</typeparam>
 /// <param name="navigation">Resource instance.</param>
 /// <returns>Newly created <typeparamref name="T" /> .</returns>
 public virtual Task <T> InsertAsync <T>(T navigation) where T : Navigation
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         return(client.PostAsync <T>(client.GetApiUrl(ModuleRelativePath), navigation));
     }
 }
Example #4
0
 /// <summary>
 /// Asynchronously insert the <see cref="FileEntry" /> into the system.
 /// </summary>
 /// <typeparam name="T">Type of extended <see cref="FileEntry" />.</typeparam>
 /// <param name="fileEntry">Resource instance.</param>
 /// <returns>Newly created <typeparamref name="T" /> .</returns>
 public virtual Task <T> InsertAsync <T>(T fileEntry) where T : FileEntry
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         return(client.PostAsync <T>(String.Format("{0}/link", client.GetApiUrl(ModuleRelativePath)), fileEntry));
     }
 }
Example #5
0
        /// <summary>
        /// Asynchronously schedule publish for specified <see cref="Notification" />.
        /// </summary>
        /// <typeparam name="T">Type of extended <see cref="Notification" />.</typeparam>
        /// <param name="notification">The notification.</param>
        /// <returns>True if <see cref="Notification" /> is scheduled for publish, false otherwise.</returns>
        public virtual async Task <bool> PublishAsync <T>(T notification) where T : Notification
        {
            if (String.IsNullOrWhiteSpace(notification.TemplateId))
            {
                throw new ArgumentNullException("TemplateId");
            }
            if (notification.Channels == null || notification.Channels.Length == 0)
            {
                throw new ArgumentNullException("Channels");
            }

            try
            {
                using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
                {
                    var httpStatusCode = await client.PostAsync <Notification, HttpStatusCode>(client.GetApiUrl(String.Format("{0}/publish/", ModuleRelativePath)), notification);

                    return(httpStatusCode == HttpStatusCode.Created);
                }
            }
            catch (BaasicClientException ex)
            {
                if (ex.ErrorCode == (int)HttpStatusCode.NotFound)
                {
                    return(false);
                }
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #6
0
 /// <summary>
 /// Asynchronously insert the <see cref="Role" /> into the system.
 /// </summary>
 /// <param name="content">Resource instance.</param>
 /// <returns>Newly created <see cref="Role" /> .</returns>
 public virtual Task <Role> InsertAsync(Role content)
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         return(client.PostAsync <Role>(client.GetApiUrl(ModuleRelativePath), content));
     }
 }
Example #7
0
 /// <summary>
 /// Asynchronously adds the <see cref="ArticleTag" /> .
 /// </summary>
 /// <typeparam name="T">Type of extended <see cref="ArticleTag" />.</typeparam>
 /// <param name="entry">The tag entry.</param>
 /// <returns>If tag is added <typeparamref name="T" /> is returned, otherwise null.</returns>
 public virtual Task <T> InsertAsync <T>(T entry) where T : ArticleTag
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         return(client.PostAsync <T>(client.GetApiUrl(ModuleRelativePath), entry));
     }
 }
 /// <summary>
 /// Asynchronously insert the <see cref="T" /> into the system.
 /// </summary>
 /// <param name="schemaName">The schema name.</param>
 /// <param name="resource">The resource.</param>
 /// <returns>Newly created <see cref="T" /> .</returns>
 public virtual Task <T> InsertAsync(string schemaName, T resource)
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         return(client.PostAsync <T>(client.GetApiUrl("{0}/{1}", ModuleRelativePath, schemaName), resource));
     }
 }
Example #9
0
 /// <summary>
 /// Asynchronously insert the collection of <see cref="Language" /> into the system.
 /// </summary>
 /// <typeparam name="T">Type of extended <see cref="Language" />.</typeparam>
 /// <param name="languages">Resource instance.</param>
 /// <returns>Collection of newly created <typeparamref name="T" /> .</returns>
 public virtual Task <T[]> InsertAsync <T>(T[] languages) where T : Language
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         return(client.PostAsync <T[]>(client.GetApiUrl(String.Format("{0}/batch", ModuleRelativePath)), languages));
     }
 }
 /// <summary>
 /// Asynchronously insert the <see cref="BlogPostStatus" /> into the system.
 /// </summary>
 /// <typeparam name="T">Type of extended <see cref="BlogPostStatus" />.</typeparam>
 /// <param name="blogPost">Resource instance.</param>
 /// <returns>Newly created <typeparamref name="T" /> .</returns>
 public virtual Task <T> InsertAsync <T>(T blogPost) where T : BlogPostStatus
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         return(client.PostAsync <T>(client.GetApiUrl(ModuleRelativePath), blogPost));
     }
 }
Example #11
0
 /// <summary>
 /// Asynchronously insert the <see cref="BlogPost" /> into the system.
 /// </summary>
 /// <typeparam name="T">Type of extended <see cref="BlogPost" />.</typeparam>
 /// <param name="blogPost">The blog post.</param>
 /// <returns>Newly created <typeparamref name="T" /> .</returns>
 public virtual Task <T> InsertAsync <T>(T blogPost) where T : BlogPost
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(ModuleRelativePath));
         return(client.PostAsync <T>(uriBuilder.ToString(), blogPost));
     }
 }
Example #12
0
 /// <summary>
 /// Asynchronously insert the collection of <see cref="Menu" /> into the system.
 /// </summary>
 /// <typeparam name="T">Type of extended <see cref="Menu" />.</typeparam>
 /// <param name="menus">Resource instance.</param>
 /// <param name="forcePositionsUpdate">True if menu needs to be saved on position no matter of existing menus.</param>
 /// <returns>Collection of newly created <typeparamref name="T" /> .</returns>
 public virtual Task <BatchResult <T>[]> InsertAsync <T>(T[] menus, bool?forcePositionsUpdate = null) where T : Menu
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(String.Format("{0}/batch", ModuleRelativePath)));
         InitializeQueryStringPair(uriBuilder, "forcePositionsUpdate", forcePositionsUpdate);
         return(client.PostAsync <T[], BatchResult <T>[]>(uriBuilder.ToString(), menus));
     }
 }
Example #13
0
 /// <summary>
 /// Asynchronously insert the <see cref="Menu" /> into the system.
 /// </summary>
 /// <typeparam name="T">Type of extended <see cref="Menu" />.</typeparam>
 /// <param name="menu">Resource instance.</param>
 /// <param name="forcePositionsUpdate">True if menu needs to be saved on position no matter of existing menus.</param>
 /// <returns>Newly created <typeparamref name="T" /> .</returns>
 public virtual Task <T> InsertAsync <T>(T menu, bool?forcePositionsUpdate = null) where T : Menu
 {
     using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
     {
         UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(ModuleRelativePath));
         InitializeQueryStringPair(uriBuilder, "forcePositionsUpdate", forcePositionsUpdate);
         return(client.PostAsync <T>(uriBuilder.ToString(), menu));
     }
 }
        /// <summary>
        /// Asynchronously schedule publish for specified <see cref="Notification" /> s.
        /// </summary>
        /// <typeparam name="T">Type of extended <see cref="Notification" />.</typeparam>
        /// <param name="notifications">The notifications.</param>
        /// <returns>True if <see cref="Notification" /> is scheduled for publish, false otherwise.</returns>
        public virtual async Task <bool> PublishAsync <T>(T[] notifications) where T : Notification
        {
            foreach (var notification in notifications)
            {
                if (String.IsNullOrWhiteSpace(notification.TemplateId))
                {
                    throw new ArgumentNullException("TemplateId");
                }
                if (notification.Channels == null || notification.Channels.Length == 0)
                {
                    throw new ArgumentNullException("Channels");
                }
            }

            using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
            {
                var httpStatusCode = await client.PostAsync <Notification[], HttpStatusCode>(client.GetApiUrl(String.Format("{0}/publish/batch/", ModuleRelativePath)), notifications);

                return(httpStatusCode == HttpStatusCode.Created);
            }
        }