コード例 #1
0
ファイル: Program.cs プロジェクト: kstatz12/simple-cqrs
        public CommandHandlerActor()
        {
            var aggregateActor = Context.ActorOf(Props.Create(() => new AggregateRootActor()), "AggregateActor");

            Receive <CreatePerson>(x =>
            {
                var personCreatedEvent = new PersonCreated(x.Model, Guid.NewGuid());
                aggregateActor.Tell(personCreatedEvent, Self);
            });
            Receive <ChangeAddress>(x =>
            {
                var personMovedEvent = new PersonMoved(x.ZipCode, x.AggregateId, x.ModelId);
                aggregateActor.Tell(personMovedEvent, Self);
            });
            Receive <ChangeName>(x =>
            {
                var personRenamedEvent = new PersonRenamed(x.FirstName, x.LastName, x.AggregateId, x.ModelId);
                aggregateActor.Tell(personRenamedEvent, Self);
            });
            Receive <RebuildAggregate>(x =>
            {
                var aggregateRebuildEvent = new AggregateRebuildInitiated(x.AggregateId);
                aggregateActor.Tell(aggregateRebuildEvent, Self);
            });
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: kstatz12/simple-cqrs
        public static void Handle(PersonCreated @event)
        {
            Store.Add(@event.Model);

            var model = @event.Model;

            Console.WriteLine("Person Saved to ReadStore: Id {0}, First Name {1}, Last Name {2}, Zip Code {3}", model.Id, model.Person.FirstName, model.Person.LastName, model.Person.ZipCode);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: kstatz12/simple-cqrs
 public void Apply(PersonCreated @event)
 {
     DomainModel = @event.Model;
 }