예제 #1
0
        public ActionResult Create(Product newProduct)
        {
            newProduct.ProductId = ++count;
            _products.Add(newProduct);

            return Json(newProduct, JsonRequestBehavior.AllowGet);
        }
예제 #2
0
        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);
        }