protected void ViewMemberAccount(string username)
        {
            var connect   = new DataClassDataContext();
            var menuList  = new List <string>();
            var menuQuery = from d in connect.users
                            where d.username != username
                            select d.username;

            menuList.AddRange(menuQuery.Distinct());
            short          currentItem = 0, c;
            ConsoleKeyInfo key;

            do
            {
                Console.Clear();
                for (c = 0; c < menuList.Count; c++)
                {
                    if (currentItem == c)
                    {
                        Console.BackgroundColor = ConsoleColor.Blue;
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine(menuList[c]);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.WriteLine(menuList[c]);
                    }
                }
                key = Console.ReadKey(true);
                if (key.Key.ToString() == "DownArrow")
                {
                    currentItem++;
                    if (currentItem > menuList.Count - 1)
                    {
                        currentItem = 0;
                    }
                }
                else if (key.Key.ToString() == "UpArrow")
                {
                    currentItem--;
                    if (currentItem < 0)
                    {
                        currentItem = Convert.ToInt16(menuList.Count - 1);
                    }
                }
            } while (key.KeyChar != 13);

            int userId = (from l in connect.users where (l.username == menuList[currentItem]) select l.id).First();
            var userAmount = (from k in connect.accounts
                              where k.user_id == userId
                              select k.amount).First();

            Console.Clear();
            Console.WriteLine("The amount of user " + menuList[currentItem] + " is: " + userAmount);
            Console.WriteLine("Press enter to go back");
            Console.ReadLine();
        }
        protected void ViewYourAccount(string username)
        {
            var connect    = new DataClassDataContext();
            int userId     = (from l in connect.users where (l.username == username) select l.id).First();
            var userAmount = (from k in connect.accounts
                              where k.user_id == userId
                              select k.amount).First();

            Console.Clear();
            Console.WriteLine("Your amount is: " + userAmount);
            Console.WriteLine("Press enter to go back");
            Console.ReadLine();
        }
        protected void DepositAdminAccount(string username)
        {
            Console.Clear();
            var connect    = new DataClassDataContext();
            int userId     = (from l in connect.users where (l.username == "admin") select l.id).First();
            var userAmount = (from k in connect.accounts
                              where k.user_id == userId
                              select k.amount).First();

            Console.Clear();
            Console.WriteLine("Please enter the amount you want to Deposit:");
            decimal deposition = 0;
            bool    isDecimal  = false;

            do
            {
                string input = Console.ReadLine();

                if (decimal.TryParse(input, out deposition))
                {
                    Console.Clear();
                    break;
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("Please enter a decimal");
                    isDecimal = true;
                }
            } while (isDecimal);
            int currentUserId = (from l in connect.users where l.username == username select l.id).First();
            var balance       = (from k in connect.accounts
                                 where k.user_id == currentUserId
                                 select k.amount).First();

            while (deposition > balance)
            {
                Console.Clear();
                Console.WriteLine("Your balance is: " + balance);
                Console.WriteLine("Please choose a smaller number!");
                deposition = Convert.ToDecimal(Console.ReadLine());
            }
            var Transfer = new BankAccount("admin", username, deposition, "deposit");

            Transfer.Transaction();
            Console.Clear();
        }
        public void Transaction()
        {
            var connect    = new DataClassDataContext();
            int userId     = (from l in connect.users where (l.username == DepositedUser) select l.id).First();
            var userAmount = from k in connect.accounts
                             where k.user_id == userId
                             select k;

            foreach (var k in userAmount)
            {
                k.amount = k.amount + TransactionAmount;
            }

            try
            {
                connect.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            userId     = (from l in connect.users where (l.username == WithdrawlUser) select l.id).First();
            userAmount = from k in connect.accounts
                         where k.user_id == userId
                         select k;

            foreach (var k in userAmount)
            {
                k.amount = k.amount - TransactionAmount;
            }

            try
            {
                connect.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }


            Console.Clear();
            Console.WriteLine(ToString());
            Console.WriteLine("Press enter to go back");
            Console.ReadLine();
        }
        public string CredentialInput()
        {
            Console.WriteLine(@"
       __          ________ _      _____ ____  __  __ ______   _______ ____          
       \ \        / /  ____| |    / ____/ __ \|  \/  |  ____| |__   __/ __ \         
        \ \  /\  / /| |__  | |   | |   | |  | | \  / | |__       | | | |  | |        
         \ \/  \/ / |  __| | |   | |   | |  | | |\/| |  __|      | | | |  | |        
          \  /\  /  | |____| |___| |___| |__| | |  | | |____     | | | |__| |        
           \/  \/   |______|______\_____\____/|_|  |_|______|____|_|  \____/         
                   |  _ \ / __ \ / ____|__   __|/\   | \ | |_   _|                   
                   | |_) | |  | | (___    | |  /  \  |  \| | | |                     
                   |  _ <| |  | |\___ \   | | / /\ \ | . ` | | |                     
                   | |_) | |__| |____) |  | |/ ____ \| |\  |_| |_                    
  _____ _   _ _____|____/_\____/|_____/ _ |_/_/    \_\_| \_|_____|        _   _ _  __
 |_   _| \ | |__   __|  ____|  __ \| \ | |   /\   | |      |  _ \   /\   | \ | | |/ /
   | | |  \| |  | |  | |__  | |__) |  \| |  /  \  | |      | |_) | /  \  |  \| | ' / 
   | | | . ` |  | |  |  __| |  _  /| . ` | / /\ \ | |      |  _ < / /\ \ | . ` |  <  
  _| |_| |\  |  | |  | |____| | \ \| |\  |/ ____ \| |____  | |_) / ____ \| |\  | . \ 
 |_____|_| \_|  |_|  |______|_|  \_\_| \_/_/    \_\______| |____/_/    \_\_| \_|_|\_\
                ");
            System.Threading.Thread.Sleep(3000);
            var connectionQuery = new DataClassDataContext();

            try
            {
                var checkConnectivity = (from k in connectionQuery.users
                                         select k).Count();
                if (checkConnectivity > 0)
                {
                    Console.WriteLine("Database Connected");
                    System.Threading.Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.Clear();

            string username         = String.Empty;
            bool   successBoolLogon = false;

            try
            {
                int counter = 3;
                do
                {
                    var credentialQuery = new DataClassDataContext();
                    Console.WriteLine("Please insert your username");
                    username = Console.ReadLine();
                    Console.WriteLine("Please insert your password");
                    string         password = String.Empty;
                    ConsoleKeyInfo info     = Console.ReadKey(true);
                    //Replaces keys on screen with *
                    while (info.Key != ConsoleKey.Enter)
                    {
                        if (info.Key != ConsoleKey.Backspace)
                        {
                            Console.Write("*");
                            password += info.KeyChar;
                        }
                        else if (info.Key == ConsoleKey.Backspace)
                        {
                            if (!string.IsNullOrEmpty(password))
                            {
                                password = password.Substring(0, password.Length - 1);
                                int pos = Console.CursorLeft;
                                Console.SetCursorPosition(pos - 1, Console.CursorTop);
                                Console.Write(" ");
                                Console.SetCursorPosition(pos - 1, Console.CursorTop);
                            }
                        }
                        info = Console.ReadKey(true);
                    }
                    Console.WriteLine();
                    password = GenerateSHA256String(password);
                    //Checks credentials to database for validity
                    var checkCredentials = (from k in credentialQuery.users
                                            where (k.username == username) && (k.password == password)
                                            select k).Count();

                    if (checkCredentials > 0)
                    {
                        Console.WriteLine("Successfull Login");
                        successBoolLogon = true;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Unsuccessfull Login - " + (counter - 1) + " more tries");
                    }
                    counter--;
                } while ((successBoolLogon == false) && (counter > 0));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.Clear();
            }

            if (successBoolLogon == false)
            {
                Console.WriteLine("Unsuccessfull Login - BYE!!!");
                username = String.Empty;
                Environment.Exit(0);
            }
            return(username);
        }
        protected void DepositMemberAccount(string username)
        {
            Console.WriteLine("Please Choose the Member account you want to deposit:");
            //gets the list of the members and their according balance
            var connect   = new DataClassDataContext();
            var menuList  = new List <string>();
            var menuQuery = from d in connect.users
                            where d.username != username
                            select d.username;

            menuList.AddRange(menuQuery.Distinct());
            short          currentItem = 0, c;
            ConsoleKeyInfo key;

            do
            {
                Console.Clear();
                for (c = 0; c < menuList.Count; c++)
                {
                    if (currentItem == c)
                    {
                        Console.BackgroundColor = ConsoleColor.Blue;
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine(menuList[c]);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.WriteLine(menuList[c]);
                    }
                }
                key = Console.ReadKey(true);
                if (key.Key.ToString() == "DownArrow")
                {
                    currentItem++;
                    if (currentItem > menuList.Count - 1)
                    {
                        currentItem = 0;
                    }
                }
                else if (key.Key.ToString() == "UpArrow")
                {
                    currentItem--;
                    if (currentItem < 0)
                    {
                        currentItem = Convert.ToInt16(menuList.Count - 1);
                    }
                }
            } while (key.KeyChar != 13);

            int userId = (from l in connect.users where (l.username == menuList[currentItem]) select l.id).First();
            var userAmount = (from k in connect.accounts
                              where k.user_id == userId
                              select k.amount).First();

            Console.Clear();
            Console.WriteLine("Please enter the amount you want to Deposit:");
            decimal deposition = 0;
            bool    isDecimal  = false;

            do
            {
                string input = Console.ReadLine();

                if (decimal.TryParse(input, out deposition))
                {
                    Console.Clear();
                    break;
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("Please enter a decimal");
                    isDecimal = true;
                }
            } while (isDecimal);

            int currentUserId = (from l in connect.users where l.username == username select l.id).First();
            var balance       = (from k in connect.accounts
                                 where k.user_id == currentUserId
                                 select k.amount).First();

            while (deposition > balance)
            {
                Console.Clear();
                Console.WriteLine("Your balance is: " + balance);
                Console.WriteLine("Please choose a smaller number!");
                isDecimal = false;
                do
                {
                    string input = Console.ReadLine();

                    if (decimal.TryParse(input, out deposition))
                    {
                        Console.Clear();
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Please enter a decimal");
                        isDecimal = true;
                    }
                } while (isDecimal);
            }

            var Transfer = new BankAccount(menuList[currentItem], username, deposition, "deposit");

            Transfer.Transaction();


            Console.Clear();
        }
 public User(string Username)
 {
     username = Username;
     var amountQuery = new DataClassDataContext();
 }