コード例 #1
0
ファイル: UpdatePostText.cs プロジェクト: klejeune/teclyn
 public async Task Execute(ICommandExecutionContext context)
 {
     await context.GetEventService().Raise(new TextUpdated
     {
         AggregateId = this.PostId,
         Text        = this.Text,
     });
 }
コード例 #2
0
ファイル: CreatePostAsDraft.cs プロジェクト: klejeune/teclyn
 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
ファイル: CreateTodoCommand.cs プロジェクト: virajs/teclyn
        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
ファイル: PropertyCommand.cs プロジェクト: virajs/teclyn
        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);
            }
        }