示例#1
0
        public override Task <IExecutionResult> Handle(Resource aggregate, CreateResourceCommand command)
        {
            if (aggregate.IsNew)
            {
                var aggregateEvent = new ResourceCreatedEvent();
                aggregate.Emit(aggregateEvent);

                var executionResult = new SuccessExecutionResult();
                return(Task.FromResult <IExecutionResult>(executionResult));
            }
            else
            {
                var executionResult = new FailedExecutionResult(new List <System.String> {
                    "aggregate is already created"
                });
                return(Task.FromResult <IExecutionResult>(executionResult));
            }
        }
示例#2
0
        public override void Handle(
            Resource aggregate,
            IActorContext context,
            CreateResourceCommand command)
        {
            if (aggregate.IsNew)
            {
                var aggregateEvent = new ResourceCreatedEvent();
                aggregate.Emit(aggregateEvent);

                var executionResult = new SuccessExecutionResult();
                context.Sender.Tell(executionResult);
            }
            else
            {
                var executionResult = new FailedExecutionResult("aggregate is already created");
                context.Sender.Tell(executionResult);
            }
        }
示例#3
0
 public void Apply(ResourceCreatedEvent aggregateEvent)
 {
     //nothing to be done
 }
示例#4
0
 public void Apply(ResourceCreatedEvent _)
 {
 }