Example #1
0
 public EpEvent Get(int id)
 {
     using (var context = new EpEfContext())
     {
         return(context.Events.First(e => e.Id == id));
     }
 }
Example #2
0
 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());
     }
 }
Example #4
0
 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);
     }
 }
Example #6
0
 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();
     }
 }