public EpEvent Get(int id) { using (var context = new EpEfContext()) { return(context.Events.First(e => e.Id == id)); } }
private static void SetupDatabase() { using (var context = new EpEfContext()) { context.Database.EnsureCreated(); } }
public IReadOnlyCollection <Person> Get() { using (var context = new EpEfContext()) { return(context.Persons.ToArray()); } }
public IReadOnlyCollection <EpEvent> GetFutureEvents(int personId) { using (var context = new EpEfContext()) { var utcNow = DateTime.UtcNow; return(context.Events.Where(e => e.Date > utcNow).ToList()); } }
public Person Get(int id) { using (var context = new EpEfContext()) { var person = context.Persons.First(p => p.Id == id); return(person); } }
public void Add(EpEvent item) { using (var context = new EpEfContext()) { var dbEvent = new DbEvent { Date = item.Date, Name = item.Name }; context.Events.Add(dbEvent); context.SaveChanges(); } }
public void Add(Person person) { using (var context = new EpEfContext()) { var dbPerson = new DbPerson { FamilyName = person.FamilyName, GivenName = person.GivenName }; context.Persons.Add(dbPerson); context.SaveChanges(); } }