Beispiel #1
0
        /// <summary>
        /// Approves the comment.
        /// </summary>
        /// <param name="commentId">The comment identifier.</param>
        /// <param name="options">The options.</param>
        /// <returns></returns>
        public virtual async Task <bool> ApproveAsync(SGuid commentId, ArticleCommentOptions options)
        {
            try
            {
                using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
                {
                    var result = await client.PutAsync <ArticleCommentOptions, HttpStatusCode>(client.GetApiUrl(String.Format("{0}/{{0}}/approve", ModuleRelativePath), commentId), options);

                    switch (result)
                    {
                    case System.Net.HttpStatusCode.Created:
                    case System.Net.HttpStatusCode.NoContent:
                    case System.Net.HttpStatusCode.OK:
                        return(true);

                    default:
                        return(false);
                    }
                }
            }
            catch (BaasicClientException ex)
            {
                if (ex.ErrorCode == (int)HttpStatusCode.NotFound)
                {
                    return(false);
                }
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Reports the comment asynchronous.
        /// </summary>
        /// <param name="commentId">The comment identifier.</param>
        /// <param name="options">The options.</param>
        /// <returns></returns>
        public virtual async Task <bool> ReportCommentAsync(SGuid commentId, ArticleCommentOptions options)
        {
            using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
            {
                var result = await client.PutAsync <ArticleCommentOptions, HttpStatusCode>(client.GetApiUrl(String.Format("{0}/{{0}}/report", ModuleRelativePath), commentId), options);

                switch (result)
                {
                case System.Net.HttpStatusCode.Created:
                case System.Net.HttpStatusCode.NoContent:
                case System.Net.HttpStatusCode.OK:
                    return(true);

                default:
                    return(false);
                }
            }
        }