public Person FindById(int id) { using (var context = new BirthdayListContext()) { return(context.People.Where(p => p.Id == id).FirstOrDefault()); } }
public List <Person> List() { using (var context = new BirthdayListContext()) { return(context.People.ToList()); } }
public void Update(Person person) { using (var context = new BirthdayListContext()) { context.Entry(person).State = EntityState.Modified; context.SaveChanges(); } }
public void Add(Person person) { using (var context = new BirthdayListContext()) { context.People.Add(person); context.SaveChanges(); } }
public List <Person> FindBirthdayToday() { using (var context = new BirthdayListContext()) { DateTime now = DateTime.Now; return(context.People.Where( p => p.Birthdate.Day == now.Day && p.Birthdate.Month == now.Month ).ToList()); } }
public void Remove(int id) { using (var context = new BirthdayListContext()) { var person = new Person { Id = id }; context.Entry(person).State = EntityState.Deleted; context.SaveChanges(); } }