Beispiel #1
0
        public async Task <APIResponse> UpdateServiceAnswer(int questionId, ServiceAnswerDetails request)
        {
            try
            {
                var client = httpClientFactory.CreateClient(VendorServiceOperation.serviceName);

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

                var response = await client.PutAsync(servicesConfig.Vendor +
                                                     VendorServiceOperation.UpdateServiceAnswer(questionId), contentPost);

                if (response.StatusCode == HttpStatusCode.NoContent)
                {
                }

                return(JsonConvert.DeserializeObject <APIResponse>(await response.Content.ReadAsStringAsync()));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'UpdateServiceAnswer()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> UpdateServiceAnswer(int answerId, [FromBody] ServiceAnswerDetails request)
        {
            var updateServiceAnswerCommand = new UpdateAnswerCommand(answerId, request);

            var result = await mediator.Send(updateServiceAnswerCommand);

            return(StatusCode((int)result.Code, result.Value));
        }
Beispiel #3
0
        public async Task <APIResponse> DeleteServiceAnswer(int questionId, ServiceAnswerDetails request)
        {
            try
            {
                var client   = httpClientFactory.CreateClient(VendorServiceOperation.serviceName);
                var response = await client.DeleteAsync(servicesConfig.Identity + VendorServiceOperation.DeleteServiceAnswer(questionId));

                return(JsonConvert.DeserializeObject <APIResponse>(await response.Content.ReadAsStringAsync()));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'DeleteBranch()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }
        public async Task <IActionResult> DeleteServiceAnswer(int questionId, [FromBody] ServiceAnswerDetails request)
        {
            var result = await serviceQuestionService.DeleteServiceAnswer(questionId, request);

            return(StatusCode((int)result.Code, result.Value));
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateAnswerCommand"/> class.
 /// </summary>
 /// <param name="serviceAnswerDetails">The service answer details.</param>
 public UpdateAnswerCommand(int questionId, ServiceAnswerDetails serviceAnswerDetails)
 {
     QuestionId           = questionId;
     ServiceAnswerDetails = serviceAnswerDetails;
 }