Пример #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 ShowSuccess(Account account)
 => ConsoleScreen.ShowMessage("Success", account.ToString(false));