Exemple #1
0
        static void Main(string[] args)
        {
            Database.Initialize();


            // Print welcome message
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Cyan;
            System.Console.WriteLine("> HOLK BANKSYSTEM");
            System.Console.WriteLine("> TYPE 'help' for commands.");
            Console.ResetColor();

            string input = "";

            while (input != "quit")
            {
                input = GetInput();

                // If statemets since we then can put the code in blocks and can use the same variable declarations

                if (input == "help")
                {
                    System.Console.WriteLine("List of commands:");
                    System.Console.WriteLine("- login           ( Authenticate a valid bank user )");
                    System.Console.WriteLine("- logout          ( Logout an authenticated bank user )");
                    System.Console.WriteLine("- quit            ( Quits the program )");

                    System.Console.WriteLine();

                    if (loggedInUser != null && !loggedInUser.Admin)
                    {
                        System.Console.WriteLine("- accounts        ( Show list of available accounts )");
                        System.Console.WriteLine("- create account  ( Create a new bank account )");
                        System.Console.WriteLine("- deposit         ( Deposit money into a bank account )");
                        System.Console.WriteLine("- withdraw        ( Withdraw money from a bank account )");
                        System.Console.WriteLine("- send            ( Send money to another bank account )");
                    }
                    else if (loggedInUser.Admin)
                    {
                        System.Console.WriteLine("- sql             ( Query the database with SQL )");
                    }
                    else
                    {
                        System.Console.WriteLine("Login for additonal commands.");
                    }
                }
                else if (input == "login")
                {
                    if (loggedInUser == null)
                    {
                        Console.Write($"{"LOGIN:"******");
                        string login = GetInput();
                        Console.Write($"{"PASSWORD:"******");
                        string password = GetInput();

                        loggedInUser            = Registry.AuthenticateUser(login, password);
                        Console.ForegroundColor = (loggedInUser == null) ? ConsoleColor.Red : ConsoleColor.Green;
                        if (loggedInUser == null)
                        {
                            System.Console.WriteLine("Invalid credentials");
                        }
                        else
                        {
                            System.Console.WriteLine("Successfully logged in");
                        }

                        Console.ResetColor();
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("You need to log out first");
                        Console.ResetColor();
                    }
                }
                else if (input == "logout")
                {
                    loggedInUser            = null;
                    Console.ForegroundColor = ConsoleColor.Green;
                    System.Console.WriteLine("Successfully logged out");
                    Console.ResetColor();
                }
                else if (input == "accounts")
                {
                    if (UserIsValid(loggedInUser))
                    {
                        // Print all accounts to the user
                        if (Registry.GetAccounts(loggedInUser.Id).Count > 0)
                        {
                            for (int i = 0; i < Registry.GetAccounts(loggedInUser.Id).Count; i++)
                            {
                                Account account = Registry.GetAccounts(loggedInUser.Id)[i];
                                // Print account infomation
                                System.Console.Write(account);
                                Console.ForegroundColor = ConsoleColor.Yellow;
                                System.Console.WriteLine($" Balance: ${account.GetBalance()}");
                                Console.ResetColor();

                                // Print all transactions to the accounts
                                if (Registry.GetAccountTransactions(account.Id).Count == 0)
                                {
                                    System.Console.WriteLine("No current transactions");
                                }
                                else
                                {
                                    for (int j = 0; j < Registry.GetAccountTransactions(account.Id).Count; j++)
                                    {
                                        Registry.GetAccountTransactions(account.Id)[j].Print();
                                    }
                                }
                                System.Console.WriteLine();
                            }
                        }
                        else
                        {
                            System.Console.WriteLine("There is currently no accounts to the user.");
                        }
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("You need to be logged in to use this command");
                        Console.ResetColor();
                    }
                }
                else if (input == "create account")
                {
                    if (UserIsValid(loggedInUser))
                    {
                        System.Console.WriteLine("Select account type:");
                        System.Console.WriteLine("1 - Checking Account");
                        System.Console.WriteLine("2 - Savings Account");
                        string accountTypeInput = GetInput();

                        if (!loggedInUser.Admin)
                        {
                            if (accountTypeInput == "1")
                            {
                                loggedInUser.AddAccount(new Account(loggedInUser, AccountTypes.Checking));
                            }

                            else if (accountTypeInput == "2")
                            {
                                loggedInUser.AddAccount(new Account(loggedInUser, AccountTypes.Savings));
                            }
                            Console.ForegroundColor = ConsoleColor.Green;
                            System.Console.WriteLine("Successfully created an account");
                            Console.ResetColor();
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            System.Console.WriteLine($"{accountTypeInput} is not a valid account type!");
                            Console.ResetColor();
                        }
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("You need to be logged in to use this command");
                        Console.ResetColor();
                    }
                }
                else if (input == "deposit")
                {
                    if (UserIsValid(loggedInUser))
                    {
                        if (Registry.GetAccounts(loggedInUser.Id).Count == 0)
                        {
                            System.Console.WriteLine("You have no current accounts");
                        }

                        System.Console.WriteLine("Select an account");
                        Account account = SelectAccount();

                        if (account != null)
                        {
                            int amount;
                            System.Console.Write("AMOUNT:");
                            bool validAmount = int.TryParse(GetInput(), out amount);
                            if (!validAmount)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                System.Console.WriteLine("Please enter a valid deposit amount");
                                Console.ResetColor();
                            }
                            // Select the account from the input

                            // Create the transaction
                            bool created = account.CreateTransaction(TransactionTypes.Deposit, amount);
                            if (created)
                            {
                                Console.ForegroundColor = ConsoleColor.Green;
                                System.Console.WriteLine($"Successfully deposited ${amount}");
                                Console.ResetColor();
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                System.Console.WriteLine($"Something went wrong creating the transaction");
                                Console.ResetColor();
                            }
                        }
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("You need to be logged in to use this command");
                        Console.ResetColor();
                    }
                }
                else if (input == "withdraw")
                {
                    if (UserIsValid(loggedInUser))
                    {
                        if (Registry.GetAccounts(loggedInUser.Id).Count == 0)
                        {
                            System.Console.WriteLine("You have no current accounts");
                        }

                        System.Console.WriteLine("Select an account");
                        Account account = SelectAccount();

                        if (account != null)
                        {
                            int amount;
                            System.Console.Write("AMOUNT:");
                            bool validAmount = int.TryParse(GetInput(), out amount);
                            if (!validAmount)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                System.Console.WriteLine("Please enter a valid withdraw amount");
                                Console.ResetColor();
                            }
                            // Select the account from the input

                            // Create the transaction
                            bool created = account.CreateTransaction(TransactionTypes.Withdraw, amount);
                            if (created)
                            {
                                Console.ForegroundColor = ConsoleColor.Green;
                                System.Console.WriteLine($"Successfully withdrew ${amount}");
                                Console.ResetColor();
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                System.Console.WriteLine($"Something went wrong creating the transaction");
                                Console.ResetColor();
                            }
                        }
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("You need to be logged in to use this command");
                        Console.ResetColor();
                    }
                }
                else if (input == "send")
                {
                    if (UserIsValid(loggedInUser))
                    {
                        if (Registry.GetAccounts(loggedInUser.Id).Count == 0)
                        {
                            System.Console.WriteLine("You have no current accounts");
                        }
                        System.Console.WriteLine("Select an account to send money from:");
                        Account fromAccount = SelectAccount();

                        if (fromAccount != null)
                        {
                            System.Console.WriteLine("Select an account to send money to:");

                            List <Account> userAccounts = new List <Account>();
                            // Print all user accounts
                            System.Console.WriteLine("Your accounts:");
                            foreach (Account account in Registry.GetAccounts(loggedInUser.Id))
                            {
                                if (account != fromAccount)
                                {
                                    userAccounts.Add(account);
                                    Console.ForegroundColor = ConsoleColor.White;
                                    System.Console.WriteLine($"     {userAccounts.Count} - {account}");
                                    Console.ResetColor();
                                }
                            }

                            foreach (User user in Registry.Users)
                            {
                                if (user != loggedInUser && user.Admin != true)
                                {
                                    System.Console.WriteLine(user.Login + ":");

                                    foreach (Account account in Registry.GetAccounts(user.Id))
                                    {
                                        userAccounts.Add(account);
                                        Console.ForegroundColor = ConsoleColor.White;
                                        System.Console.WriteLine($"     {userAccounts.Count} - {account}");
                                        Console.ResetColor();
                                    }
                                }
                            }

                            int receiverIndex;


                            if (int.TryParse(GetInput(), out receiverIndex))
                            {
                                receiverIndex -= 1;
                                if (receiverIndex < userAccounts.Count)
                                {
                                    Account receiverAccount = userAccounts[receiverIndex];


                                    int amount;
                                    System.Console.Write("AMOUNT:");
                                    bool validAmount = int.TryParse(GetInput(), out amount);
                                    if (!validAmount)
                                    {
                                        Console.ForegroundColor = ConsoleColor.Red;
                                        System.Console.WriteLine("Please enter a valid deposit amount");
                                        Console.ResetColor();
                                    }
                                    else
                                    {
                                        // Select the account from the input

                                        // Create the transaction
                                        bool created = fromAccount.CreateTransaction(TransactionTypes.Send, amount, receiverAccount.Id);
                                        if (created)
                                        {
                                            Console.ForegroundColor = ConsoleColor.Green;
                                            System.Console.WriteLine($"Successfully sended ${amount} to ${receiverAccount}");
                                            Console.ResetColor();
                                        }
                                        else
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            System.Console.WriteLine($"Something went wrong creating the transaction");
                                            Console.ResetColor();
                                        }
                                    }
                                }
                                else
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    System.Console.WriteLine("There is currently no other user accounts");
                                    Console.ResetColor();
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                System.Console.WriteLine("Invalid user input");
                                Console.ResetColor();
                            }
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            System.Console.WriteLine("You need to be logged in to use this command");
                            Console.ResetColor();
                        }
                    }
                    else if (input == "quit")
                    {
                        System.Console.WriteLine("Goodbye!");
                    }
                    else
                    {
                        if (input.Length > 0)
                        {
                            System.Console.WriteLine($"{input} is not a valid command!");
                        }
                    }
                }
                else if (input == "sql")
                {
                    if (loggedInUser.Admin)
                    {
                        string sqlInput = "";
                        System.Console.WriteLine("Type '.views' to see a list of available views");
                        System.Console.WriteLine("Type '.quit' to quit the sql prompt");

                        while (sqlInput != ".quit")
                        {
                            sqlInput = GetInput(">");

                            if (sqlInput == ".views")
                            {
                                System.Console.WriteLine("Available views:");
                                System.Console.WriteLine("- system_flags                ( Get all flagged users and the reason )");
                                System.Console.WriteLine("- user_accounts               ( Get all accounts for each user )");
                                System.Console.WriteLine("- user_transactions           ( Get all transactions to each account )");
                                System.Console.WriteLine("- account_transactions_count  ( Show count of transactions on each account )");
                            }
                            else
                            {
                                // Run the query
                                var records = Database.QueryRecords(sqlInput);

                                Console.ForegroundColor = ConsoleColor.Magenta;
                                Database.PrettyPrintRecords(records);
                                Console.ResetColor();
                            }
                        }
                    }
                    else
                    {
                        System.Console.WriteLine("You need to be an admin to use this command");
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            // Initialize the registry
            Registry registry = new Registry();

            // Create a sample users
            var sampleUser = new User("sample", "password");

            sampleUser.AddAccount(new CheckingAccount(0.015));
            sampleUser.AddAccount(new SavingsAccount(0.025, 500, 250));

            sampleUser.Accounts[0].CreateTransaction(TransactionTypes.Deposit, 250);
            sampleUser.Accounts[0].CreateTransaction(TransactionTypes.Deposit, 50);
            sampleUser.Accounts[0].CreateTransaction(TransactionTypes.Withdraw, 50);
            sampleUser.Accounts[0].CreateTransaction(TransactionTypes.Deposit, 3500);

            sampleUser.Accounts[1].CreateTransaction(TransactionTypes.Deposit, 500);

            registry.AddUser(sampleUser);

            // Create a sample users
            var sampleUser2 = new User("sample2", "password");

            sampleUser2.AddAccount(new CheckingAccount(0.015));
            sampleUser2.AddAccount(new SavingsAccount(0.025, 250, 250));

            sampleUser2.Accounts[0].CreateTransaction(TransactionTypes.Deposit, 250);

            sampleUser2.Accounts[1].CreateTransaction(TransactionTypes.Deposit, 1500);

            registry.AddUser(sampleUser2);

            // Print welcome message
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Cyan;
            System.Console.WriteLine("> HOLK BANKSYSTEM");
            System.Console.WriteLine("> TYPE 'help' for commands.");
            Console.ResetColor();

            string input = "";

            while (input != "quit")
            {
                input = GetInput();

                // If statemets since we then can put the code in blocks and can use the same variable declarations

                if (input == "help")
                {
                    System.Console.WriteLine("List of commands:");
                    System.Console.WriteLine("- login           ( Authenticate a valid bank user )");
                    System.Console.WriteLine("- logout          ( Logout an authenticated bank user )");
                    System.Console.WriteLine("- quit            ( Quits the program )");

                    System.Console.WriteLine();

                    if (loggedInUser != null)
                    {
                        System.Console.WriteLine("- accounts        ( Show list of available accounts )");
                        System.Console.WriteLine("- create account  ( Create a new bank account )");
                        System.Console.WriteLine("- deposit         ( Deposit money into a bank account )");
                        System.Console.WriteLine("- withdraw        ( Withdraw money from a bank account )");
                        System.Console.WriteLine("- send            ( Send money to another bank account )");
                    }
                    else
                    {
                        System.Console.WriteLine("Login for additonal commands.");
                    }
                }
                else if (input == "login")
                {
                    if (loggedInUser == null)
                    {
                        Console.Write($"{"LOGIN:"******");
                        string login = GetInput();
                        Console.Write($"{"PASSWORD:"******");
                        string password = GetInput();

                        loggedInUser            = registry.AuthenticateUser(login, password);
                        Console.ForegroundColor = (loggedInUser == null) ? ConsoleColor.Red : ConsoleColor.Green;
                        if (loggedInUser == null)
                        {
                            System.Console.WriteLine("Invalid credentials");
                        }
                        else
                        {
                            System.Console.WriteLine("Successfully logged in");
                        }

                        Console.ResetColor();
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("You need to log out first");
                        Console.ResetColor();
                    }
                }
                else if (input == "logout")
                {
                    loggedInUser            = null;
                    Console.ForegroundColor = ConsoleColor.Green;
                    System.Console.WriteLine("Successfully logged out");
                    Console.ResetColor();
                }
                else if (input == "accounts")
                {
                    if (UserIsValid(loggedInUser))
                    {
                        // Print all accounts to the user
                        if (loggedInUser.Accounts.Count > 0)
                        {
                            for (int i = 0; i < loggedInUser.Accounts.Count; i++)
                            {
                                Account account = loggedInUser.Accounts[i];
                                // Print account infomation
                                System.Console.Write(account);
                                Console.ForegroundColor = ConsoleColor.Yellow;
                                System.Console.WriteLine($" Balance: ${account.GetBalance()}");
                                Console.ResetColor();

                                // Print all transactions to the accounts
                                if (account.Transactions.Count == 0)
                                {
                                    System.Console.WriteLine("No current transactions");
                                }
                                else
                                {
                                    for (int j = 0; j < account.Transactions.Count; j++)
                                    {
                                        account.Transactions[j].Print();
                                    }
                                }
                                System.Console.WriteLine();
                            }
                        }
                        else
                        {
                            System.Console.WriteLine("There is currently no accounts to the user.");
                        }
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("You need to be logged in to use this command");
                        Console.ResetColor();
                    }
                }
                else if (input == "create account")
                {
                    if (UserIsValid(loggedInUser))
                    {
                        System.Console.WriteLine("Select account type:");
                        System.Console.WriteLine("1 - Checking Account");
                        System.Console.WriteLine("2 - Savings Account");
                        string accountTypeInput = GetInput();
                        if (accountTypeInput == "1")
                        {
                            loggedInUser.AddAccount(new CheckingAccount(2.6));
                        }

                        else if (accountTypeInput == "2")
                        {
                            loggedInUser.AddAccount(new SavingsAccount(10.5, 500, 250));
                        }

                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            System.Console.WriteLine($"{accountTypeInput} is not a valid account type!");
                            Console.ResetColor();
                        }

                        Console.ForegroundColor = ConsoleColor.Green;
                        System.Console.WriteLine("Successfully created an account");
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("You need to be logged in to use this command");
                        Console.ResetColor();
                    }
                }
                else if (input == "deposit")
                {
                    if (UserIsValid(loggedInUser))
                    {
                        if (loggedInUser.Accounts.Count == 0)
                        {
                            System.Console.WriteLine("You have no current accounts");
                        }

                        System.Console.WriteLine("Select an account");
                        Account account = SelectAccount();

                        if (account != null)
                        {
                            int amount;
                            System.Console.Write("AMOUNT:");
                            bool validAmount = int.TryParse(GetInput(), out amount);
                            if (!validAmount)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                System.Console.WriteLine("Please enter a valid deposit amount");
                                Console.ResetColor();
                            }
                            // Select the account from the input

                            // Create the transaction
                            bool created = account.CreateTransaction(TransactionTypes.Deposit, amount);
                            if (created)
                            {
                                Console.ForegroundColor = ConsoleColor.Green;
                                System.Console.WriteLine($"Successfully deposited ${amount}");
                                Console.ResetColor();
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                System.Console.WriteLine($"Something went wrong creating the transaction");
                                Console.ResetColor();
                            }
                        }
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("You need to be logged in to use this command");
                        Console.ResetColor();
                    }
                }
                else if (input == "withdraw")
                {
                    if (UserIsValid(loggedInUser))
                    {
                        if (loggedInUser.Accounts.Count == 0)
                        {
                            System.Console.WriteLine("You have no current accounts");
                        }

                        System.Console.WriteLine("Select an account");
                        Account account = SelectAccount();

                        if (account != null)
                        {
                            int amount;
                            System.Console.Write("AMOUNT:");
                            bool validAmount = int.TryParse(GetInput(), out amount);
                            if (!validAmount)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                System.Console.WriteLine("Please enter a valid withdraw amount");
                                Console.ResetColor();
                            }
                            // Select the account from the input

                            // Create the transaction
                            bool created = account.CreateTransaction(TransactionTypes.Withdraw, amount);
                            if (created)
                            {
                                Console.ForegroundColor = ConsoleColor.Green;
                                System.Console.WriteLine($"Successfully withdrew ${amount}");
                                Console.ResetColor();
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                System.Console.WriteLine($"Something went wrong creating the transaction");
                                Console.ResetColor();
                            }
                        }
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("You need to be logged in to use this command");
                        Console.ResetColor();
                    }
                }
                else if (input == "send")
                {
                    if (UserIsValid(loggedInUser))
                    {
                        if (loggedInUser.Accounts.Count == 0)
                        {
                            System.Console.WriteLine("You have no current accounts");
                        }
                        System.Console.WriteLine("Select an account to send money from:");
                        Account fromAccount = SelectAccount();

                        if (fromAccount != null)
                        {
                            System.Console.WriteLine("Select an account to send money to:");

                            List <Account> userAccounts = new List <Account>();
                            // Print all user accounts
                            System.Console.WriteLine("Your accounts:");
                            foreach (Account account in loggedInUser.Accounts)
                            {
                                if (account != fromAccount)
                                {
                                    userAccounts.Add(account);
                                    System.Console.WriteLine($"     {userAccounts.Count} - {account}");
                                }
                            }
                            System.Console.WriteLine("User accounts:");

                            foreach (User user in registry.users)
                            {
                                if (user != loggedInUser)
                                {
                                    System.Console.WriteLine(user);

                                    foreach (Account account in user.Accounts)
                                    {
                                        userAccounts.Add(account);
                                        System.Console.WriteLine($"     {userAccounts.Count} - {account}");
                                    }
                                }
                            }

                            int receiverIndex;


                            if (int.TryParse(GetInput(), out receiverIndex))
                            {
                                receiverIndex -= 1;
                                if (receiverIndex < userAccounts.Count)
                                {
                                    Account receiverAccount = userAccounts[receiverIndex];


                                    int amount;
                                    System.Console.Write("AMOUNT:");
                                    bool validAmount = int.TryParse(GetInput(), out amount);
                                    if (!validAmount)
                                    {
                                        Console.ForegroundColor = ConsoleColor.Red;
                                        System.Console.WriteLine("Please enter a valid deposit amount");
                                        Console.ResetColor();
                                    }
                                    else
                                    {
                                        // Select the account from the input

                                        // Create the transaction
                                        bool created = fromAccount.CreateTransaction(TransactionTypes.Send, amount, ref fromAccount, ref receiverAccount);
                                        if (created)
                                        {
                                            Console.ForegroundColor = ConsoleColor.Green;
                                            System.Console.WriteLine($"Successfully sended ${amount} to ${receiverAccount}");
                                            Console.ResetColor();
                                        }
                                        else
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            System.Console.WriteLine($"Something went wrong creating the transaction");
                                            Console.ResetColor();
                                        }
                                    }
                                }
                                else
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    System.Console.WriteLine("There is currently no other user accounts");
                                    Console.ResetColor();
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                System.Console.WriteLine("Invalid user input");
                                Console.ResetColor();
                            }
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            System.Console.WriteLine("You need to be logged in to use this command");
                            Console.ResetColor();
                        }
                    }
                    else if (input == "quit")
                    {
                        System.Console.WriteLine("Goodbye!");
                    }
                    else
                    {
                        if (input.Length > 0)
                        {
                            System.Console.WriteLine($"{input} is not a valid command!");
                        }
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            Console.Clear();
            Registry registry = new Registry();

            registry.AddUser(new User[] {
                new Admin("admin", "password"),
                new Admin("admin2", "password"),
                new User("user1", "password"),
                new User("user3", "password"),
                new User("Test User", "password2"),
            });

            System.Console.WriteLine($"REGISTRY: USERS: {registry.GetUsers().Count(i => i.IsAdmin() == false)}, ADMINS: {registry.GetUsers().Count(i => i.IsAdmin() == true)}");
            // Print all available users
            registry.GetUsers().ForEach(i => System.Console.WriteLine(i));
            System.Console.WriteLine();

            // Create some sample jobs
            HourlyPaidJob hourlyPaidJob = new HourlyPaidJob(200);

            // Create a task for the job
            // Work for 8 hours
            hourlyPaidJob.CreateTask(async() => {
                for (int i = 1; i <= 8; i++)
                {
                    System.Console.WriteLine($"      HourlyPaidJob Hour: {i}");
                    await Task.Delay(250);
                    // Add an hour to the job
                    hourlyPaidJob.AddHours(1);
                }
                // Print the Monthly Payout
                System.Console.WriteLine($"      GetMonthlyPay: {hourlyPaidJob.GetMonthlyPay()}");
            });
            // 1600 pay each day
            DailyPaidJob dailyPaidJob = new DailyPaidJob(1600);

            // Create a task for the job
            // Work for 20 days
            dailyPaidJob.CreateTask(async() => {
                for (int i = 0; i < 20; i++)
                {
                    System.Console.WriteLine($"         DailyPaidJob Day: {i}");
                    await Task.Delay(1000);
                    // Add an hour to the job
                    dailyPaidJob.AddDays(1);
                }
                // Print the Monthly Payout
                System.Console.WriteLine($"         GetMonthlyPay: {dailyPaidJob.GetMonthlyPay()}");
            });



            // Get the testuser from the authentication from the registry
            var user_1 = registry.AuthenticateUser("user1", "password");

            if (user_1 != null)
            {
                // Give the user a job
                user_1.SetJob(hourlyPaidJob);

                // Start the user job
                user_1.StartJob();
            }

            // Create a new user
            // Pass the dailypaid job to the constructor instead
            registry.AddUser(new User("user2", "password", dailyPaidJob));
            // Authenticate another user
            var user_2 = registry.AuthenticateUser("user2", "password");

            if (user_2 != null)
            {
                // Start the user job
                user_2.StartJob();
            }


            // Demostrate the chaning of a user password with a admin user

            // Create the user and add it to the registry
            var sampleUser = new User("sample_password_user", "secretpassword");

            registry.AddUser(sampleUser);
            System.Console.WriteLine($"{sampleUser} OLD PASSWORD: {sampleUser.password}");
            // Login into an admin account and change the user password

            var admin = (Admin)registry.AuthenticateUser("admin", "password");

            System.Console.WriteLine(admin);
            if (admin != null)
            {
                // Change the password
                admin.ChangeUserPassword(sampleUser, "$$$$ADMIN CHANGED PASSWORD$$$$");
            }
            System.Console.WriteLine($"{sampleUser} NEW PASSWORD: {sampleUser.password}");

            // Wait for application
            Console.ReadLine();
        }