void Inserir(Person p) { ClovisApplicationTestingEntities contexto = new ClovisApplicationTestingEntities(); contexto.Person.Add(p); contexto.SaveChanges(); }
void Excluir(int id) { Person pExcluir = BuscarPorID(id); if (pExcluir != null) { ClovisApplicationTestingEntities contexto = new ClovisApplicationTestingEntities(); contexto.Person.Remove(pExcluir); contexto.SaveChanges(); } }
void Editar(int id, Person novosDadosPerson) { Person personAntigo = BuscarPorID(id); if (personAntigo != null) { personAntigo.FirstName = novosDadosPerson.FirstName; personAntigo.LastName = novosDadosPerson.LastName; personAntigo.Title = novosDadosPerson.Title; ClovisApplicationTestingEntities contexto = new ClovisApplicationTestingEntities(); contexto.Entry(personAntigo).State = System.Data.Entity.EntityState.Modified; contexto.SaveChanges(); } }