Exemplo n.º 1
0
        // function that authenticates user
        public void Login()
        {
            Console.Write("Enter your username: "******"Enter your password: "******"Logged in : " + username);
                new AccountScreen(res.UserId, res.AuthKey).Run();
                return;
            }
            else
            {
                Console.WriteLine("Error : " + res.Errors);
                Login();
                return;
            }
        }
Exemplo n.º 2
0
        public override void Run(bool clearScreen = true)
        {
            if (clearScreen)
            {
                Console.Clear();
            }
            Console.WriteLine($"Deposit for {User.Username}\n");
            Console.Write("Enter amount to deposit: ");
            var amount = UserInputHelper.GetDecimal();

            Console.Write($"Depost {amount:C}. Are you sure? (y/n) : ");
            var confirm = Console.ReadLine();

            if (confirm == "y" || confirm == "Y")
            {
                var res = UserTransactionService.Deposit(User.Id, amount);
                if (res.Success)
                {
                    Console.WriteLine("Deposit Success!");
                }
                else
                {
                    Console.WriteLine($"Deposit Failed. {res.Errors}");
                }
            }
            else
            {
                Console.WriteLine("Deposit Cancelled!");
            }
            ShowDoneOptions();
        }
Exemplo n.º 3
0
        public override void Run(bool clearScreen = true)
        {
            if (clearScreen)
            {
                Console.Clear();
            }
            Console.WriteLine($"Withdrawal for {User.Username}");
            Console.WriteLine($"Availabe for withdrawal: {UserTransactionService.GetCurrentBalanceForUser(User.Id):C}\n");

            Console.Write("Enter amount to withdraw: ");
            var amount = UserInputHelper.GetDecimal();

            Console.Write($"Withdraw {amount:C}. Are you sure? (y/n) : ");
            var confirm = Console.ReadLine();

            if (confirm == "y" || confirm == "Y")
            {
                var res = UserTransactionService.Withdraw(User.Id, amount);
                if (res.Success)
                {
                    Console.WriteLine("Withdrawal Success!");
                }
                else
                {
                    Console.WriteLine($"Withdrawal Failed. {res.Errors}");
                }
            }
            else
            {
                Console.WriteLine("Withdrawal Cancelled!");
            }
            ShowDoneOptions();
        }
Exemplo n.º 4
0
        // function that registers new user
        public void Register()
        {
            Console.Write("Enter your username: "******"Enter your password: "******"Re-enter your password: "******"Passwords not matched.");
                Register();
                return;
            }

            var user = new User
            {
                Username = username,
                Password = pass
            };

            var res = new AuthService().Register(user);

            if (res.Success)
            {
                Console.WriteLine("Registered : " + username);

                new LoginScreen().Run(false);
                return;
            }
            else
            {
                Console.WriteLine("Error : " + res.Errors);
                Register();
                return;
            }
        }