public static void LoginValidation() { BankAccount dailyBuffer = new BankAccount(); dailyBuffer.MemoryBuffer = new List <User>(); int count = 0; do { ++count; Console.WriteLine("Login Screen"); Console.Write("Please enter your Username: "******"Please enter your password: "******"*"); } else { if (key.Key == ConsoleKey.Backspace && password.Length > 0) { password = password.Substring(0, (password.Length - 1)); Console.Write("\b \b"); } } } // Stops Receving Keys Once Enter is Pressed while (key.Key != ConsoleKey.Enter); Console.ForegroundColor = ConsoleColor.White; password = DataAccess.GenerateSHA256String(password); int id = DataAccess.GetUserID(username); string usernameDB = DataAccess.GetUsername(id); string passwordDB = DataAccess.GetPassword(id); if (usernameDB == username && passwordDB == password) { dailyBuffer.MemoryBuffer = ApplicationMenu.GetApplicationMenu(id, dailyBuffer.MemoryBuffer); break; } else { Console.WriteLine(" "); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid Password or Username"); Console.WriteLine(" "); Console.ForegroundColor = ConsoleColor.White; } }while (count < 3); if (count == 3) { Application.Exit(); } }
public static List <User> Transfer(User loginUser, List <User> memoryBuffer) { User thirdParty = new User(); loginUser.Balance = DataAccess.GetUserBalance(loginUser.ID); loginUser.Transaction = "Transfer"; bool validation = false; do { Console.WriteLine(""); Console.Write("Insert destination's account username: "******"Invalid Transaction!"); Console.WriteLine("Same account"); Console.ForegroundColor = ConsoleColor.White; validation = false; } } while (validation == false); do { Console.WriteLine(""); Console.Write("Your current balance: "); Console.ForegroundColor = ConsoleColor.Green; Console.Write(loginUser.Balance + " "); Console.ForegroundColor = ConsoleColor.White; Console.Write("Enter amount: "); Console.ForegroundColor = ConsoleColor.Green; loginUser.TransactionAmount = Convert.ToDecimal(Console.ReadLine()); validation = ValidateAmount(loginUser.ID, loginUser.TransactionAmount, memoryBuffer); Console.ForegroundColor = ConsoleColor.White; } while (validation == false); thirdParty.ID = DataAccess.GetUserID(thirdParty.Username); DisplayTransferInfo(loginUser, thirdParty.Username); Console.WriteLine(""); Console.Write("Confirm transaction and proceed? Y/N: "); string choice = Console.ReadLine(); if (choice == "Y" || choice == "y") { DataAccess.AddToBalance(thirdParty.ID, loginUser.TransactionAmount); DataAccess.SubtractToBalance(loginUser.ID, loginUser.TransactionAmount); Console.WriteLine(Environment.NewLine + Environment.NewLine + "Transaction Successful!"); loginUser.DestiationAccountName = thirdParty.Username; memoryBuffer = BankAccount.GetUserListOfDaysActivity(loginUser, memoryBuffer); thirdParty.Transaction = "Transfer"; thirdParty.SenderAccountName = loginUser.Username; thirdParty.TransactionAmount = loginUser.TransactionAmount; memoryBuffer = BankAccount.GetUserListOfDaysActivity(thirdParty, memoryBuffer); } else { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(Environment.NewLine + "Transaction was canceled"); Console.ForegroundColor = ConsoleColor.White; ApplicationMenu.GetApplicationMenu(loginUser.ID, memoryBuffer); } return(memoryBuffer); }