Ejemplo n.º 1
0
        private static void SimulateAccountProcessing(ICommandBus commandBus)
        {
            var newAccountId  = Guid.NewGuid();
            var createAccount = new CreateAccount(newAccountId, "Omar", @"Besiso", "ThoughtDesign",
                                                  RandomGenerator.GenerateRandomEmail());

            try
            {
                commandBus.Send(createAccount);

                //Simulate 6 snapshots
                for (var i = 0; i < 60; i++)
                {
                    var updateAccount = new UpdateAccountAddress(newAccountId, $"Test {i}", null, null, null, null,
                                                                 "Australia");
                    commandBus.Send(updateAccount);
                }

                var approveAccount = new ApproveAccount(newAccountId, "Omar Besiso");
                commandBus.Send(approveAccount);

                var deleteAccount = new DeleteAccount(newAccountId, "Testing");
                commandBus.Send(deleteAccount);

                var reinstateAccount = new ReinstateAccount(newAccountId);
                commandBus.Send(reinstateAccount);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private static void SimulateAccountProcessing(ICommandBus commandBus, IQueryProcessor queryProcessor)
        {
            for (int y = 0; y < 10; y++)
            {
                var newAccountId  = Guid.NewGuid();
                var createAccount = new CreateAccount(newAccountId, "Omar", @"Besiso", "ThoughtDesign",
                                                      RandomGenerator.GenerateRandomEmail());

                try
                {
                    commandBus.Send(createAccount);

                    //Simulate 2 snapshots
                    for (var i = 0; i < 10; i++)
                    {
                        var updateAccount = new UpdateAccountAddress(newAccountId, $"Test {i}", null, null, null, null,
                                                                     "Australia");
                        commandBus.Send(updateAccount);
                    }

                    var approveAccount = new ApproveAccount(newAccountId, "Omar Besiso");
                    commandBus.Send(approveAccount);

                    var deleteAccount = new DeleteAccount(newAccountId, "Testing");
                    commandBus.Send(deleteAccount);

                    var reinstateAccount = new ReinstateAccount(newAccountId);
                    commandBus.Send(reinstateAccount);

                    var query    = new GetAccountDetailsById(newAccountId);
                    var response = queryProcessor.ProcessQuery <GetAccountDetailsById, GetAccountDetailsByIdResponse>(query);

                    Console.WriteLine(response.AccountDetailsDto.AccountId);
                    Console.WriteLine(response.AccountDetailsDto.BusinessName);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }