public void RutTien() { if (Program.currentLoggedInAccount != null) { Console.Clear(); Console.WriteLine("Tiến hành rút tiền tại Hệ thống Ngân hàng Blockchain."); Console.WriteLine("Vui lòng nhập số tiền cần rút: "); var amount = double.Parse(Console.ReadLine()); if (amount <= 0) { Console.WriteLine("Số lượng tiền không hợp lệ, vui lòng thử lại."); return; } var transaction = new SHBTransaction { TransactionId = Guid.NewGuid().ToString(), SenderAccountNumber = Program.currentLoggedInAccount.AccountNumber, ReceiverAccountNumber = Program.currentLoggedInAccount.AccountNumber, Type = 1, Message = "Tiến hành rút tiền ở ATM với số tiền: " + amount, Amount = amount, CreatedAtMLS = DateTime.Now.Ticks, UpdatedAtMLS = DateTime.Now.Ticks, Status = 1 }; BlockchainTransaction blockchainTransaction; bool result = BlockchainAddressModel.UpdateBalance(Program.currentLoggedInAccount, typeof(BlockchainTransaction)); } else { Console.WriteLine("Vui lòng đăng nhập lại để sử dụng chức năng này."); } }
public void Withdrawal() { if (Program.CurrentLoggedInAccount != null) { Console.Clear(); Console.WriteLine("===== Withdrawal on Blockchain ====="); Console.WriteLine("Enter your amount: "); var amount = double.Parse(Console.ReadLine()); if (amount <= 0) { Console.WriteLine("Your amount is unavaiable. Please try again."); return; } var transaction = new SHBTransaction { TransactionId = Guid.NewGuid().ToString(), SenderAccountId = Program.CurrentLoggedInAccount.AccountNumber, ReceiverAccountId = Program.CurrentLoggedInAccount.AccountNumber, Type = 1, Message = "Withdrawal completed: " + amount, Amount = amount, CreatedAtMLS = DateTime.Now.Ticks, UpdatedAtMLS = DateTime.Now.Ticks, Status = 1 }; BlockchainTransaction blockchainTransaction; bool result = BlockchainAddressModel.UpdateBalance(Program.CurrentLoggedInAccount, typeof(BlockchainTransaction)); } else { Console.WriteLine("Please login your account to use this function."); } }
public void Login() { Program.currentLoggedInAccount = null; Console.Clear(); Console.WriteLine("Tiến hành đăng nhập Hệ thống Ngân hàng Blockchain."); Console.WriteLine("Vui lòng điền tên truy cập: "); var address = Console.ReadLine(); Console.WriteLine("Vui lòng nhập mật khẩu: "); var privatekey = Console.ReadLine(); var blockchainAccount = BlockchainAddressModel.FindByAddrssAndPrivateKey(address, privatekey); if (blockchainAccount == null) { Console.WriteLine("Sai tài khoản, vui lòng thử lại."); Console.WriteLine("Ấn enter để tiếp tục."); Console.Read(); return; } Program.currentLoggedInAccount = blockchainAccount as SHBAccount; }
public void Login() { Program.CurrentLoggedInAccount = null; Console.Clear(); Console.WriteLine("Login Blockchain System."); Console.WriteLine("Address: "); var address = Console.ReadLine(); Console.WriteLine("Private Key: "); var privatekey = Console.ReadLine(); var blockchainAccount = BlockchainAddressModel.FindByAddrssAndPrivateKey(address, privatekey); if (blockchainAccount == null) { Console.WriteLine("Wrong Address or Private Key. Please try again."); Console.WriteLine("Press any key to continue."); Console.Read(); return; } Program.CurrentLoggedInAccount = blockchainAccount as SHBAccount; }
public GiaoDichBlockchain() { blockchainAddressModel = new BlockchainAddressModel(); }