public void Handle()
        {
            using (var context = new PlanningPokerDbContext())
            {
                var eventRecord = new EventRecord(modelEvent);

                context.EventRecords.Add(eventRecord);

                context.SaveChanges();

                modelEvent.id = eventRecord.Id;

                var model = new ModelQuery().Execute();

                var snapshot = new Snapshot
                {
                    Id = modelEvent.id.Value,
                    Data = model.ToJson(),
                    EventRecord = eventRecord
                };

                context.Snapshots.Add(snapshot);

                context.SaveChanges();
            }
        }
        private static void PopulateDatabaseWithExampleValues()
        {
            using (var context = new PlanningPokerDbContext())
            {
                context.Database.ExecuteSqlCommand("DELETE FROM [EventRecord]");
                context.Database.ExecuteSqlCommand("DELETE FROM [Snapshot]");
            }

            var events = ExampleEvents.Get();

            foreach (var modelEvent in events)
            {
                new AddEventCommand(modelEvent).Handle();
            }
        }
        public IEnumerable<ModelEvent> Execute()
        {
            using (var context = new PlanningPokerDbContext())
            {
                var events = context
                    .EventRecords
                    .OrderBy(r => r.Id)
                    .Select(r => new { r.Id, r.Data })
                    .ToArray()
                    .Select(r =>
                    {
                        var modelEvent = JsonConvert.DeserializeObject<ModelEvent>(r.Data);
                        modelEvent.id = r.Id;
                        return modelEvent;
                    })
                    .ToArray();

                return events;
            }
        }