Пример #1
0
        public async Task <ProductGetDTO> CreateAsync(ProductPostDTO product)
        {
            try {
                String json = JsonConvert.SerializeObject(product, new JsonSerializerSettings {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                });
                StringContent       data     = new StringContent(json, Encoding.UTF8, "application/json");
                HttpResponseMessage response = await this.client.PostAsync(apiUrl + "/product-management/products", data);

                string result = await ResponseUtility.Verification(response);

                return(JsonConvert.DeserializeObject <ProductGetDTO>(result));
            }
            catch (ServicesException ex)
            {
                throw ex;
            }
            catch (Exception e)
            {
                throw new ServicesException("Product api not found", 408);
            }
        }
Пример #2
0
 public IActionResult Post([FromBody] ProductPostDTO product)
 {
     return(Ok(_productService.CreateAsync(product).Result));
 }