public ActionResult EditProductAction(AddProductModel pm) { using (WMEntities db = new WMEntities()) { var p = db.Products.Where(x => x.Id == pm.Id).FirstOrDefault(); p.Name = pm.Name; p.Price = pm.Price; p.Producer = pm.Producer; p.ProductCategoryId = pm.CategoryId; p.Supplier = pm.Supplier; db.SaveChanges(); } return(Json("OK")); }
public ActionResult AddProductAction(AddProductModel pm) { using (WMEntities db = new WMEntities()) { db.Products.Add(new Product() { Name = pm.Name, Price = pm.Price, Producer = pm.Producer, ProductCategoryId = pm.CategoryId, Supplier = pm.Supplier }); db.SaveChanges(); } return(Json("OK")); }