예제 #1
0
파일: Program.cs 프로젝트: jableader/cshite
        static void Withdraw(Bank bank)
        {
            while (true)
            {
                var screen = new ConsoleScreen("Withdraw");
                screen.AddText("Enter the details", TextJustification.Center);
                var account = screen.AddInput("Account Number: ", Validate.AsAccount(bank));
                var amount  = screen.AddInput("Amount: $", Validate.Money());

                if (!screen.Show())
                {
                    return;
                }
                else if (amount.Response <= account.Response.Balance)
                {
                    bank.Transact(account.Response, -amount.Response);
                    ShowSuccess(account.Response);

                    return;
                }
                else if (!ConsoleScreen.ShowConfirmation("You're too broke", "The selected account's balance is too low.", "Would you like to try again (y/n)? ", ConsoleColor.Black, ConsoleColor.Red))
                {
                    return;
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: jableader/cshite
        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}.");
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: jableader/cshite
        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.");
                }
            }
        }