示例#1
0
 public async Task Execute(ICommandExecutionContext context)
 {
     await context.GetEventService().Raise(new TextUpdated
     {
         AggregateId = this.PostId,
         Text        = this.Text,
     });
 }
示例#2
0
 public async Task Execute(ICommandExecutionContext context)
 {
     await context.GetEventService().Raise(new CreatedAsDraft
     {
         AggregateId = this.PostId,
         Title       = this.PostTitle,
     });
 }
示例#3
0
 public async Task Execute(ICommandExecutionContext context)
 {
     await context.GetEventService().Raise(new Published
     {
         AggregateId     = this.PostId,
         PublicationDate = context.GetTimeService().Now(),
     });
 }
示例#4
0
 public async Task Execute(ICommandExecutionContext context)
 {
     this.Result = await context.GetEventService().Raise(new TodoListCreatedEvent
     {
         AggregateId = context.GetIdGenerator().GenerateId(),
         Name        = this.Name,
         Date        = context.GetTimeService().Now(),
     });
 }
示例#5
0
 public async Task Execute(RegisterUserCommand command, ICommandExecutionContext context)
 {
     await context.GetEventService().Raise(new Registered
     {
         AggregateId      = command.Username,
         EmailAddress     = command.EmailAddress,
         RegistrationDate = context.GetTimeService().Now(),
     });
 }
示例#6
0
 public async Task Execute(ICommandExecutionContext context)
 {
     await context.GetEventService().Raise(new ErrorLoggedEvent
     {
         Message     = this.Message,
         AggregateId = context.GetIdGenerator().GenerateId(),
         Description = this.Description,
     });
 }
示例#7
0
        public async Task Execute(ICommandExecutionContext context)
        {
            var list = await this.TodoLists.GetById(this.TodoListId);

            this.Result = await context.GetEventService().Raise(new TodoCreatedEvent
            {
                AggregateId  = context.GetIdGenerator().GenerateId(),
                Text         = this.Text,
                TodoListId   = list.Id,
                TodoListName = list.Name,
            });
        }
示例#8
0
        public override async Task Execute(ICommandExecutionContext context)
        {
            var repository = context.Teclyn.Get <IRepository <TAggregate> >();
            var aggregate  = await repository.GetById(this.AggregateId);

            var oldValue = this.PropertyAccessor(aggregate);

            if (oldValue == null && this.NewValue != null || oldValue != null && !oldValue.Equals(NewValue))
            {
                var @event = Activator.CreateInstance <TEvent>();
                @event.OldValue    = oldValue;
                @event.NewValue    = this.NewValue;
                @event.AggregateId = this.AggregateId.Value;

                await context.GetEventService().Raise(@event);
            }
        }