public void AddPerson(Person person) { using (var context = new InternshipDbEntities()) { context.People.Add(person); context.SaveChanges(); } }
public void DeletePerson(int personId) { using (var context = new InternshipDbEntities()) { var person = context.People.Where(x => x.Id == personId).SingleOrDefault(); if (person != null) { context.People.Remove(person); context.SaveChanges(); } } }
public void UpdatePerson(Person person) { using (var context = new InternshipDbEntities()) { var personObj = context.People.Where(x => x.Id == person.Id).SingleOrDefault(); if (personObj != null) { personObj.Name = person.Name; context.SaveChanges(); } } }