Пример #1
0
        /// <summary>
        /// Gets the CommentReply.
        /// </summary>
        /// <param name="commentReplyParametersRequest">The CommentReply parameters request.</param>
        /// <returns></returns>
        public async Task <APIResponse> GetCommentReplies(CommentReplyParametersRequest commentReplyParametersRequest)
        {
            try
            {
                var client = httpClientFactory.CreateClient(BlogServiceOperation.serviceName);

                UriBuilder url = new UriBuilder(servicesConfig.Blog + BlogServiceOperation.GetCommentReplies());
                url.Query = QueryStringHelper.ConvertToQueryString(commentReplyParametersRequest);

                var response = await client.GetAsync(url.ToString());

                if (response.IsSuccessStatusCode)
                {
                    var commentReply = JsonConvert.DeserializeObject <List <CommentReplyResponse> >(await response.Content.ReadAsStringAsync());
                    return(new APIResponse(commentReply, HttpStatusCode.OK));
                }

                return(new APIResponse(response.StatusCode));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'GetCommentReplies()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }