private void btnAdd_Click(object sender, EventArgs e) { try { IProductApiService service = new IProductApiService(); service.Create(new ServiceDLL.Models.ProductAddModel { Name = txtName.Text, Price = Convert.ToDecimal(txtPrice.Text), Image = _base64Image }); } catch (WebException wex) { if (wex.Response != null) { using (var errorResponse = (HttpWebResponse)wex.Response) { using (var reader = new StreamReader(errorResponse.GetResponseStream())) { string error = reader.ReadToEnd(); MessageBox.Show(error); //TODO: use JSON.net to parse this string and look at the error message } } } MessageBox.Show("Гюстон у нас проблеми"); } }
public IActionResult Create([FromBody] ProductEntity product) { return(Ok(_productApiService.Create(product))); }
public IHttpActionResult Create([FromBody] ProductDto product) { var id = _service.Create(product); return(CreatedAtRoute(nameof(FindOne), new { id }, id)); // Relies on Name= on FindOne !! }