private static void CreateAccountRequest(string name)
        {
            Console.WriteLine($"Request create account for {name}");

            Console.WriteLine("Validate request");
            var list = _database.GetAccounts();

            if (list.Any(a => a.Name == name))
            {
                Console.WriteLine("Validation failed: Account already exists.");
                return;
            }

            Console.WriteLine("Validation succeeded - execute command.");
            _router.Send(new CreateAccountCommand(Guid.NewGuid(), name));
        }
        private static void Main()
        {
            Console.WriteLine("CQRSlite Banking Account sample");

            // Infrastructure setup
            _database   = new InMemoryDatabase();
            _router     = new Router();
            _eventStore = new InMemoryEventStore(_router);

            var locator   = new ServiceLocator(_router, _eventStore, _database);
            var registrar = new RouteRegistrar(locator);

            registrar.RegisterHandlers(
                typeof(AccountCommandsHandler),
                typeof(BankAccountsListView)
                );

            // start using it
            Console.WriteLine("Create bank accounts");
            CreateAccountRequest("Frank");
            CreateAccountRequest("Peter");

            PayInRequest("Frank", 15);
            TransferRequest("Frank", "Peter", 10);
            PayOutRequest("Peter", 5);

            Console.WriteLine("First read model: List of available bank accounts");
            var list = _database.GetAccounts();

            foreach (var account in list)
            {
                var balance = _database.GetAccountBalanceDto(account.Id);
                Console.WriteLine($"Account {account.Name}: {balance.Balance}");
            }

            Console.WriteLine("Sample done.");
            Console.ReadLine();
        }