public ActionResult Create(Product newProduct) { newProduct.ProductId = ++count; _products.Add(newProduct); return Json(newProduct, JsonRequestBehavior.AllowGet); }
public ActionResult Update(int id, Product updatedProduct) { var product = _products.FirstOrDefault(x => x.ProductId == id); _products.Remove(product); _products.Add(updatedProduct); return Json(updatedProduct, JsonRequestBehavior.AllowGet); }