/// <summary>
        /// Creates the Multidetail.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public async Task <APIResponse> CreateMultiDetails(CreateMultidetailEcommerceRequest request)
        {
            try
            {
                var client = httpClientFactory.CreateClient(ECommerceServiceOperation.serviceName);

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

                var response = await client.PostAsync(servicesConfig.ECommerce + ECommerceServiceOperation.CreateMultiDetails(), contentPost);

                if (response.IsSuccessStatusCode)
                {
                    var multidetail = JsonConvert.DeserializeObject <MultidetailResponse>(await response.Content.ReadAsStringAsync());
                    return(new APIResponse(multidetail, HttpStatusCode.Created));
                }

                return(new APIResponse(response.StatusCode));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'CreateMultiDetails()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }
Exemple #2
0
        //[Authorize(Roles = "Admin, Vendor")]
        public async Task <IActionResult> CreateMultiDetails([FromBody] CreateMultidetailEcommerceRequest request)
        {
            var result = await multidetailService.CreateMultiDetails(request);

            return(StatusCode((int)result.Code, result.Value));
        }