Exemplo n.º 1
0
        public async Task Delete(Guid aggregateId)
        {
            using (var context = await _frameworkContextFactor.CreateContext())
            {
                var snapshot = context.Snapshots.SingleOrDefault(s => s.AggregateId == aggregateId);

                if (snapshot != null)
                {
                    context.Snapshots.Remove(snapshot);
                    await context.SaveChangesAsync(); //Todo: CT
                }
            }
        }
Exemplo n.º 2
0
        public async Task Delete(Guid stateId)
        {
            using (var context = await _frameworkContextFactory.CreateContext())
            {
                var state = context.EventHandlerStates.SingleOrDefault(s => s.Id == stateId);

                if (state != null)
                {
                    context.EventHandlerStates.Remove(state);
                    await context.SaveChangesAsync();
                }
            }
        }
Exemplo n.º 3
0
        // GDRP method - Consider scrambling events instead?
        public async Task Delete(Guid aggregateId)
        {
            using (var context = await _frameworkContextFactory.CreateContext())
            {
                var eventsToDelete = await context.Events
                                     .Where(e => e.AggregateId == aggregateId)
                                     .ToListAsync();

                context.Events.RemoveRange(eventsToDelete);

                await context.SaveChangesAsync(); // Todo: CT
            }
        }
Exemplo n.º 4
0
        public async Task Save(ICommand command)
        {
            using (var context = await _frameworkContextFactory.CreateContext(command.Id))
            {
                context.Sessions.Add(new Models.Session
                {
                    Id               = command.Id,
                    CompletedDate    = DateTimeOffset.Now, //Todo: Time service?
                    ComittedByUserId = command.UserId,
                    Type             = command.GetType().AssemblyQualifiedName,
                    Data             = _commandSerializer.Serialize(command),
                });

                await context.SaveChangesAsync();
            }
        }