public bool EditPerson(PersonVM p) { using (var context = new RepositoryDemoEntities()) { var result = new PersonService(context).EditPerson(new EntityFramework.TPerson { Name = p.Name, Home = p.Home, Age = p.Age, Id = p.PersonID }); context.SaveChanges(); return(result); } }
public bool AddPerson(PersonVM p) { using (var context = new RepositoryDemoEntities()) { context.Configuration.AutoDetectChangesEnabled = true; var result = new PersonService(context).AddPerson(new EntityFramework.TPerson { Name = p.Name, Home = p.Home, Age = p.Age, Id = p.PersonID }); context.SaveChanges(); return(result); } }
public bool AddPersons(List <PersonVM> persons) { var list = new List <TPerson>(); persons.ForEach(p => list.Add(new TPerson { Name = p.Name, Home = p.Home, Age = p.Age, Id = p.PersonID })); using (var context = new RepositoryDemoEntities()) { var result = new PersonService(context).AddPersons(list); context.SaveChanges(); return(result); } }