public ActionResult ContactTypes_Create([DataSourceRequest]DataSourceRequest request, ContactType contactType) { if (ModelState.IsValid) { var entity = new ContactType { Name = contactType.Name, ModifiedDate = contactType.ModifiedDate }; db.ContactTypes.Add(entity); db.SaveChanges(); contactType.ContactTypeID = entity.ContactTypeID; } return Json(new[] { contactType }.ToDataSourceResult(request, ModelState)); }
public ActionResult ContactTypes_Destroy([DataSourceRequest]DataSourceRequest request, ContactType contactType) { if (ModelState.IsValid) { var entity = new ContactType { ContactTypeID = contactType.ContactTypeID, Name = contactType.Name, ModifiedDate = contactType.ModifiedDate }; db.ContactTypes.Attach(entity); db.ContactTypes.Remove(entity); db.SaveChanges(); } return Json(new[] { contactType }.ToDataSourceResult(request, ModelState)); }
public ActionResult ContactTypes_Update([DataSourceRequest]DataSourceRequest request, ContactType contactType) { if (ModelState.IsValid) { var entity = new ContactType { ContactTypeID = contactType.ContactTypeID, Name = contactType.Name, ModifiedDate = contactType.ModifiedDate }; db.ContactTypes.Attach(entity); db.Entry(entity).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return Json(new[] { contactType }.ToDataSourceResult(request, ModelState)); }