public ActionResult CreateLogger(zone zo) { if (ModelState.IsValid) { using (var northwind = new hercules_dbEntities()) { // Create a new Product entity and set its properties from the posted ProductViewModel var entity = new zone { ZoneName = zo.ZoneName, Status = true, CreationDate = DateTime.Now }; // Add the entity northwind.zones2.Add(entity); // Insert the entity in the database northwind.SaveChanges(); // Get the ProductID generated by the database } } return Redirect("List"); }
public ActionResult Edit([DataSourceRequest] DataSourceRequest request, zone product) { // DataClasses1DataContext dt = new DataClasses1DataContext(); if (product != null) // && ModelState.IsValid { using (var db = new hercules_dbEntities()) { var result = from u in db.zones2 where (u.ID == product.ID) select u; if (result.Count() != 0) { var dbuser = result.First(); dbuser.ZoneName = product.ZoneName; dbuser.Status = product.Status.Value; db.SaveChanges(); } } } return Json(new[] { product }.ToDataSourceResult(request, ModelState)); }