public ActionResult ProductModels_Create([DataSourceRequest]DataSourceRequest request, ProductModel productModel) { if (ModelState.IsValid) { var entity = new ProductModel { Name = productModel.Name, CatalogDescription = productModel.CatalogDescription, Instructions = productModel.Instructions, rowguid = Guid.NewGuid(), ModifiedDate =DateTime.Now }; db.ProductModels.Add(entity); db.SaveChanges(); productModel.ProductModelID = entity.ProductModelID; } return Json(new[] { productModel }.ToDataSourceResult(request, ModelState)); }
public ActionResult ProductModels_Destroy([DataSourceRequest]DataSourceRequest request, ProductModel productModel) { if (ModelState.IsValid) { var entity = new ProductModel { ProductModelID = productModel.ProductModelID, Name = productModel.Name, CatalogDescription = productModel.CatalogDescription, Instructions = productModel.Instructions, rowguid = productModel.rowguid, ModifiedDate = productModel.ModifiedDate }; db.ProductModels.Attach(entity); db.ProductModels.Remove(entity); db.SaveChanges(); } return Json(new[] { productModel }.ToDataSourceResult(request, ModelState)); }
public ActionResult ProductModels_Update([DataSourceRequest]DataSourceRequest request, ProductModel productModel) { if (ModelState.IsValid) { var entity = new ProductModel { ProductModelID = productModel.ProductModelID, Name = productModel.Name, CatalogDescription = productModel.CatalogDescription, Instructions = productModel.Instructions, rowguid = productModel.rowguid, ModifiedDate = DateTime.Now }; db.ProductModels.Attach(entity); db.Entry(entity).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return Json(new[] { productModel }.ToDataSourceResult(request, ModelState)); }