Пример #1
0
        static void CreateNewAccount(Bank bank)
        {
            var screen    = new ConsoleScreen(Art.AsHeader("Create a new account", Art.Hello));
            var firstName = screen.AddInput("First Name: ", Validate.Name());
            var lastName  = screen.AddInput("Last Name: ", Validate.Name());
            var address   = screen.AddInput("Address: ", Validate.AsString(3));
            var phone     = screen.AddInput("Phone: ", Validate.NumberBetween(0, 99_9999_9999));
            var email     = screen.AddInput("Email: ", Validate.Email());

            screen.Show();

            if (ConsoleScreen.ShowConfirmation("Confirm new account", "Are you sure you would like to create this account?"))
            {
                var account = bank.CreateAccount(firstName.Response, lastName.Response, address.Response, email.Response, phone.Response);
                ConsoleScreen.ShowMessage("Account Created", $"Created new account with ID {account.ID}.");
            }
        }
Пример #2
0
        static void DeleteAccount(Bank bank)
        {
            var screen = new ConsoleScreen(Art.AsHeader("Delete account", Art.Goodbye), ConsoleColor.Yellow, ConsoleColor.Red);

            screen.AddText("Enter the details", TextJustification.Center);

            var account = screen.AddInput("Account number: ", Validate.AsAccount(bank));

            if (screen.Show())
            {
                if (ConsoleScreen.ShowConfirmation("DELETE", "About to delete this account: \r\n" + account.Response.ToString(false), forground: ConsoleColor.Red))
                {
                    bank.Delete(account.Response);
                    ConsoleScreen.ShowMessage("Account deleted", "Account was successfully deleted.");
                }
            }
        }
Пример #3
0
        static void Login()
        {
            while (true)
            {
                var screen = new ConsoleScreen(Art.AsHeader(Title, Art.BitCoin));
                screen.AddText("Login to start");
                screen.AddBlankLines();

                var username = screen.AddInput("User name: ", Validate.AsString());
                var password = screen.AddPassword("Password: "******"Login Error", "Username-password combination was not valid.");
            }
        }
Пример #4
0
        static void WelcomeScreen()
        {
            var bank = new Bank("accounts");

            while (true)
            {
                var console = new ConsoleScreen(Art.AsHeader(Title, Art.BitCoin));
                console.AddText(@"1. Create a new account
2. Search for an account
3. Deposit
4. Withdraw
5. A/C statement
6. Delete Account
7. Exit
 ");
                var choice = console.AddInput("Enter your choice (1-7): ", Validate.NumberBetween(1, 7));
                console.Show();

                switch (choice.Response)
                {
                case 1: CreateNewAccount(bank); break;

                case 2: SearchForAccount(bank); break;

                case 3: Deposit(bank); break;

                case 4: Withdraw(bank); break;

                case 5: AccountStatement(bank); break;

                case 6: DeleteAccount(bank); break;

                default: return;
                }
            }
        }
Пример #5
0
        static void AccountStatement(Bank bank)
        {
            var screen  = new ConsoleScreen(Art.AsHeader("Statement"));
            var account = screen.AddInput("Account number: ", Validate.AsAccount(bank));

            if (screen.Show())
            {
                screen = new ConsoleScreen(Art.AsHeader($"Statement of {account.Response.ID}"));
                screen.AddText($"Account Balance: ${account.Response.Balance.ToString("0.00")}");
                screen.AddSeperator(" \r\n%\r\n ");
                foreach (var transaction in account.Response.Transactions)
                {
                    screen.AddText(transaction.ToString("$0.00"), forgroundColor: transaction < 0 ? ConsoleColor.Red : ConsoleColor.White);
                }

                screen.AddSeperator(" \r\n \r\n -");

                var shouldEmail = screen.AddInput($"Email to {account.Response.Email} (y/n)?", Validate.Bool(), ConsoleColor.Green, ConsoleColor.Black);
                if (screen.Show() && shouldEmail.Response)
                {
                    // No email functionality
                }
            }
        }