public void Create([FromBody] Product product) { if (ModelState.IsValid) { objprod.AddProduct(product); } }
public bool CreateProduct() { Stream req = Request.InputStream; req.Seek(0, System.IO.SeekOrigin.Begin); string json = new StreamReader(req).ReadToEnd(); var product = JsonConvert.DeserializeObject <Dictionary <string, string> >(json); Product newProduct = new Product(); if (product.ContainsKey("Name") && "" != product["Name"]) { newProduct.Name = product["Name"]; } else { return(false); } if (product.ContainsKey("Price")) { decimal price = 0; try { price = Convert.ToDecimal(product["Price"]); } catch (Exception) { return(false); } newProduct.Price = price; } return(productDAL.AddProduct(newProduct)); }
public IActionResult Create([Bind] Product product) { if (ModelState.IsValid) { objProduct.AddProduct(product); return(RedirectToAction("Index")); } return(View(product)); }
public Product Post([FromBody] Product product) { return(ObjectProduct.AddProduct(product)); }
public int AddProduct(Product product) { return(objProductDAL.AddProduct(product)); }
public int Create([FromBody] Product product) { return(objProduct.AddProduct(product)); }
public int Create(Product product) { return(objProduct.AddProduct(product)); }