public ActionResult People_Create([DataSourceRequest]DataSourceRequest request, HRM.Models.Person person) { if (ModelState.IsValid) { var entity = new HRM.Models.Person { BusinessEntityID = person.BusinessEntityID, PersonType = person.PersonType, NameStyle = person.NameStyle, Title = person.Title, FirstName = person.FirstName, MiddleName = person.MiddleName, LastName = person.LastName, Suffix = person.Suffix, EmailPromotion = person.EmailPromotion, rowguid = person.rowguid, ModifiedDate = DateTime.Now }; db.People.Add(entity); db.SaveChanges(); person.BusinessEntityID = entity.BusinessEntityID; } return Json(new[] { person }.ToDataSourceResult(request, ModelState)); }
public ActionResult People_Update([DataSourceRequest]DataSourceRequest request, HRM.Models.Person person) { if (ModelState.IsValid) { var entity = new HRM.Models.Person { BusinessEntityID = person.BusinessEntityID, PersonType = person.PersonType, NameStyle = person.NameStyle, Title = person.Title, FirstName = person.FirstName, MiddleName = person.MiddleName, LastName = person.LastName, Suffix = person.Suffix, EmailPromotion = person.EmailPromotion, AdditionalContactInfo = person.AdditionalContactInfo, Demographics = person.Demographics, rowguid = person.rowguid, ModifiedDate = DateTime.Now }; db.People.Attach(entity); db.Entry(entity).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return Json(new[] { person }.ToDataSourceResult(request, ModelState)); }