public void Login() { Console.WriteLine("Vui lòng nhập thông tin đăng nhập."); Console.WriteLine("Tài khoản: "); var username = Console.ReadLine(); Console.WriteLine("Mật khẩu: "); var password = Console.ReadLine(); var acc = model.GetAccountByUsername(username); if (acc != null) { MainThread.currentLoggedInAccount = acc; Console.WriteLine("Login thành công với tên là " + MainThread.currentLoggedInAccount.UserName); return; } Console.WriteLine("Sai thông tin đăng nhập."); }
public void ChuyenTien() { if (Program.currentLoggedInAccount != null) { Console.WriteLine("Tiến hành chuyển tiền tại hệ thống SHB."); Console.WriteLine("Vui lòng nhập số tài khoản chuyển tiền: "); var accountNumber = Console.ReadLine(); var receiverAccount = shbAccountModel.GetAccountByAccountNumber(accountNumber); if (receiverAccount == null) { Console.WriteLine("Tài khoản nhận tiền không tồn tại hoặc đã bị khoá."); return; } Console.WriteLine("Tài khoản nhận tiền: " + accountNumber); Console.WriteLine("Chủ tài khoản: " + receiverAccount.Username); Console.WriteLine("Nhập số tiền chuyển khoản: "); var amount = double.Parse(Console.ReadLine()); Program.currentLoggedInAccount = shbAccountModel.GetAccountByUsername(Program.currentLoggedInAccount.Username); if (amount > Program.currentLoggedInAccount.Balance) { Console.WriteLine("Số dư tài khoản không đủ thực hiện giao dịch."); return; } Console.WriteLine("Nhập nội dung giao dịch: "); var message = Console.ReadLine(); var shbTransaction = new SHBTransaction() { TransactionId = Guid.NewGuid().ToString(), Type = SHBTransaction.TransactionType.TRANSFER, Amount = amount, Message = message, CreateAtMLS = DateTime.Now.Ticks, UpdateAtMLS = DateTime.Now.Ticks, Status = SHBTransaction.TransactionStatus.DONE, SenderAccountNumber = Program.currentLoggedInAccount.AccountNumber, ReceiverAccountNumber = accountNumber }; if (shbAccountModel.Transfer(Program.currentLoggedInAccount, shbTransaction)) { Console.WriteLine("Giao dịch thành công."); } else { Console.WriteLine("Giao dịch thất bại, vui lòng thử lại."); } } }
public void Transfer() { if (Program.currentLoggedInAccount != null) { Console.WriteLine("Transfer money at the banking system SHB."); Console.WriteLine("Please enter the account number you want to transfer: "); var accountNumber = Console.ReadLine(); var receiverAccount = shbAccountModel.GetAccountByAccountNumber(accountNumber); if (receiverAccount == null) { Console.WriteLine("Money receiving account does not exist or has been locked, please check again."); return; } Console.WriteLine("Money receiving account: " + accountNumber); Console.WriteLine("account holder: " + receiverAccount.Username); Console.WriteLine("Enter the amount you want to transfer: "); var amount = double.Parse(Console.ReadLine()); Program.currentLoggedInAccount = shbAccountModel.GetAccountByUsername(Program.currentLoggedInAccount.Username); if (amount > Program.currentLoggedInAccount.Balance) { Console.WriteLine("Account balance is not enough to make transactions."); return; } Console.WriteLine("Enter transaction content: "); var message = Console.ReadLine(); var shbTransaction = new SHBTransaction() { TransactionId = Guid.NewGuid().ToString(), Type = SHBTransaction.TransactionType.TRANSFER, Amount = amount, Message = message, CreateAtMLS = DateTime.Now.Ticks, UpdateAtMLS = DateTime.Now.Ticks, Status = SHBTransaction.TransactionStatus.DONE, SenderAccountNumber = Program.currentLoggedInAccount.AccountNumber, ReceiverAccountNumber = accountNumber }; if (shbAccountModel.Transfer(Program.currentLoggedInAccount, shbTransaction)) { Console.WriteLine("Successful transaction."); } else { Console.WriteLine("The transaction failed, please check again."); } } }