public void DeletePerson(int id) { using (TestowaContext db = new TestowaContext()) { db.People.Remove(db.People.Single(g => g.Id == id)); db.SaveChanges(); } }
public void AddPerson(string firstName, string lastName, int phonNumber) { using (TestowaContext db = new TestowaContext()) { db.People.Add(new People() { FirstName = firstName, LastName = lastName, PhoneNumber = phonNumber }); db.SaveChanges(); } }
public void ModifyPerson(int id, string firstName, string lastName, int phonNumber) { using (TestowaContext db = new TestowaContext()) { People person = new People() { Id = id, FirstName = firstName, LastName = lastName, PhoneNumber = phonNumber }; db.Entry(person).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); } }