Ejemplo n.º 1
0
 public void Store(UncommittedEventStream events)
 {
     _context.WithConnection(connection =>
                             _context.WithTransaction(connection, transaction =>
     {
         SaveEventSources(events, transaction);
         SaveEvents(events, transaction);
         UpdateEventSources(events, transaction);
     }));
 }
Ejemplo n.º 2
0
        public void Save(IEventSource source)
        {
            var events = source.GetUncommittedEvents();

            _context.WithConnection(connection =>
                                    _context.WithTransaction(connection, transaction =>
            {
                var currentVersion = GetVersion(source.EventSourceId, transaction);

                if (currentVersion == null)
                {
                    AddEventSource(source, transaction);
                }
                else if (currentVersion.Value != source.InitialVersion)
                {
                    throw new ConcurrencyException(source.EventSourceId, source.Version);
                }

                SaveEvents(events, source.EventSourceId, transaction);
                UpdateEventSourceVersion(source, transaction);
            }));
        }