Esempio n. 1
0
        public static void Main(string[] args)
        {
            //Create actor system
            var system = ActorSystem.Create("useraccount-example");


            //Build create user account aggregate command
            var aggregateId = UserAccountId.New;
            var createUserAccountCommand = new CreateUserAccountCommand(aggregateId, "foo bar");

            //Send command, this is equivalent to command.publish() in other cqrs frameworks
            //system.PublishCommandAsync(createUserAccountCommand);

            var changeNameCommand = new UserAccountChangeNameCommand(aggregateId, "foo bar baz");

            //system.PublishCommandAsync(changeNameCommand);

            //block end of program
            Console.ReadLine();
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            //Create actor system
            var system = ActorSystem.Create("useraccount-example");

            //Create supervising aggregate manager for UserAccount aggregate root actors
            var aggregateManager = system.ActorOf(Props.Create(() => new UserAccountAggregateManager()));

            //Build create user account aggregate command
            var aggregateId = UserAccountId.New;
            var createUserAccountCommand = new CreateUserAccountCommand(aggregateId, "foo bar");

            //Send command, this is equivalent to command.publish() in other cqrs frameworks
            aggregateManager.Tell(createUserAccountCommand);

            var changeNameCommand = new UserAccountChangeNameCommand(aggregateId, "foo bar baz");

            aggregateManager.Tell(changeNameCommand);

            //block end of program
            Console.ReadLine();
        }
Esempio n. 3
0
        public static async Task Main(string[] args)
        {
            //var upcaster = new UserAccountAggregateEventUpcaster();

            //var oldevt = new CommittedEvent<UserAccountAggregate,UserAccountId,UserAccountNameChangedEvent>(UserAccountId.New,new UserAccountNameChangedEvent("test"),null);
            //var
            //var evt1 = upcaster.FromJournal(oldevt, String.Empty);
            //Console.WriteLine("Ok");
            //var evt = upcaster.Upcast(oldevt);
            //Console.WriteLine(evt);

            //Create actor system
            var system = ActorSystem.Create("useraccount-example", Config.Postgres);

            //Create supervising aggregate manager for UserAccount aggregate root actors
            var aggregateManager = system.ActorOf(Props.Create(() => new UserAccountAggregateManager()));

            //Build create user account aggregate command
            //var aggregateId = UserAccountId.New;
            //var createUserAccountCommand = new CreateUserAccountCommand(aggregateId, "foo bar");

            //Send command, this is equivalent to command.publish() in other cqrs frameworks
            //aggregateManager.Tell(createUserAccountCommand);
            var aggregateId = UserAccountId.With("useraccount-a40e3a87-6ebf-4900-884d-7c17477ea20b");

            while (true)
            {
                var newName           = GetRandomString();
                var changeNameCommand = new UserAccountChangeNameCommand(aggregateId, newName);
                aggregateManager.Tell(changeNameCommand);
                await Task.Delay(1000);
            }

            //block end of program
            Console.WriteLine("done");
            Console.ReadLine();
        }
Esempio n. 4
0
 public bool Execute(UserAccountChangeNameCommand command)
 {
     ChangeName(command.Name);
     return(true);
 }
Esempio n. 5
0
 public IExecutionResult Execute(UserAccountChangeNameCommand command)
 {
     ChangeName(command.Name);
     return(ExecutionResult.Success());
 }