public IActionResult CreateProduct(IFormCollection valueCollection) { string code = valueCollection["i_code"]; string name = valueCollection["i_name"]; string description = valueCollection["i_description"]; string priceStr = valueCollection["i_price"]; try { decimal price = 0; bool priceToDecimal = Decimal.TryParse(priceStr, out price); ProductManagement pm = new ProductManagement(); CreateProductModel model = new CreateProductModel() { Code = code, Name = name, Description = description, Price = price }; CreateProductResultModel result = pm.Create(model); } catch (Exception ex) { return(new ContentResult() { Content = "An error has occurred: " + Environment.NewLine + ex.Message }); } return(RedirectToAction("Search")); }
// CREATE api/product (body) public IHttpActionResult Post(Product product) { var productoManager = new ProductManagement(); productoManager.Create(product); apiResponse = new ApiResponse(); return(Ok(apiResponse)); }