コード例 #1
0
        /// <summary>
        /// Deletes the Review.
        /// </summary>
        /// <param name="details">The details.</param>
        /// <returns></returns>
        public async Task <APIResponse> DeleteReview(ReviewIdDetails details)
        {
            try
            {
                var client = httpClientFactory.CreateClient(BlogServiceOperation.serviceName);

                var response = await client.DeleteAsync(servicesConfig.Blog + BlogServiceOperation.DeleteReview(details.ReviewId));

                return(new APIResponse(response.StatusCode));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'DeleteReview()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }
コード例 #2
0
        /// <summary>
        /// Updates the Review.
        /// </summary>
        /// <param name="details">The details.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public async Task <APIResponse> UpdateReview(ReviewIdDetails details, UpdateReviewBlogRequest request)
        {
            try
            {
                var client = httpClientFactory.CreateClient(BlogServiceOperation.serviceName);

                var         param       = JsonConvert.SerializeObject(request);
                HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json");

                var response = await client.PutAsync(servicesConfig.Blog + BlogServiceOperation.UpdateReview(details.ReviewId), contentPost);

                return(new APIResponse(response.StatusCode));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'UpdateReview()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets the Review.
        /// </summary>
        /// <param name="details">The details.</param>
        /// <returns></returns>
        public async Task <APIResponse> GetReview(ReviewIdDetails details)
        {
            try
            {
                var client   = httpClientFactory.CreateClient(BlogServiceOperation.serviceName);
                var response = await client.GetAsync(servicesConfig.Blog + BlogServiceOperation.GetReview(details.ReviewId));

                if (response.IsSuccessStatusCode)
                {
                    //var review = JsonConvert.DeserializeObject<ReviewResponseDetails>(await response.Content.ReadAsStringAsync());
                    var review = JsonConvert.DeserializeObject <ReviewResponse>(await response.Content.ReadAsStringAsync());
                    return(new APIResponse(review, HttpStatusCode.OK));
                }

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