Exemplo n.º 1
0
        public void RutTien()
        {
            if (Program.CurrentAddress != null)
            {
                Console.Clear();
                Console.WriteLine("Tien hanh rut tien tai he thong Blockchain.");
                Console.WriteLine("Vui long nhap so tien can rut.");
                var amount = double.Parse(Console.ReadLine());
                if (amount <= 0)
                {
                    Console.WriteLine("So luong khong hop le, vui long thu lai.");
                    return;
                }

                var transaction = new BlockchainTransaction {
                    TransactionId   = Guid.NewGuid().ToString(),
                    SenderAddress   = Program.CurrentAddress.Address,
                    ReceiverAddress = Program.CurrentAddress.Address,
                    Type            = BlockchainTransaction.TransactionType.WITHDRAW,
                    Amount          = amount,
                    CreatedAtMLS    = DateTime.Now.Ticks,
                    UpdateAtMLS     = DateTime.Now.Ticks,
                    Status          = 1
                };

                bool result = _model.UpdateBalance(Program.CurrentAddress, transaction);
            }
            else
            {
                Console.WriteLine("Vui long dang nhap lai de su dung chuc nang nay.");
            }
        }
        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.");
            }
        }
Exemplo n.º 3
0
        public void RutTien()
        {
            if (Program.currentLoggedInAddress != null)
            {
                Console.Clear();
                Console.WriteLine("Tien hanh rut tien tai blockchain.");
                Console.WriteLine("Nhap so tien can rut.");
                decimal amount = decimal.Parse(Console.ReadLine());
                if (amount <= 0)
                {
                    Console.WriteLine("So luong khong hop le, vui long thu lai.");
                    return;
                }

                var transaction = new BlockchainTransaction()
                {
                    TransactionId   = Guid.NewGuid().ToString(),
                    SenderAddress   = Program.currentLoggedInAddress.Address,
                    ReceiverAddress = Program.currentLoggedInAddress.Address,
                    Amount          = amount,
                    CreatedAtMLS    = DateTime.Now.Ticks,
                    UpdatedAtMLS    = DateTime.Now.Ticks,
                    Status          = 1
                };
                bool result = blockchainAccountModel.UpdateBalance(Program.currentLoggedInAddress, transaction);
                if (result)
                {
                    Console.WriteLine("Thanh cong");
                }
            }
            else
            {
                Console.WriteLine("Dang nhap de su dung chuc nang nay.");
            }
        }
Exemplo n.º 4
0
        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.");
            }
        }