コード例 #1
0
ファイル: AccountManager.cs プロジェクト: VorXal/xt_net_web
 public bool CanCreateAccount(string newLogin, string newPassword)
 {
     foreach (Account account in _accountDAO.GetAllAccounts())
     {
         if (account.Login.Equals(newLogin))
         {
             return(false);
         }
     }
     if (newLogin.Length < 3 || newPassword.Length < 3)
     {
         return(false);
     }
     //TODO: Validation Password
     return(true);
 }
コード例 #2
0
 public List <Account> GetAllAccounts()
 {
     return(accountDAO.GetAllAccounts());
 }
コード例 #3
0
        private MenuOptionResult SendTEBucks()
        {
            List <DisplayAccount> accounts = accountDAO.GetAllAccounts();

            accounts = accounts.Where(a => a.AccountId != UserService.GetUserId()).ToList();

            Console.WriteLine("-----------------------------------------");
            Console.WriteLine($"Users");
            Console.WriteLine($"{"ID", -11}{"Name", -10}");
            Console.WriteLine("-----------------------------------------");

            foreach (DisplayAccount account in accounts)
            {
                Console.WriteLine($"{account.AccountId, -10} {account.Username, -10}");
            }

            bool validId     = false;
            int  accountToId = -1;

            while (!validId)
            {
                accountToId = GetInteger("Enter ID of user you are sending to (0 to cancel): ");

                if (accountToId == 0)
                {
                    return(MenuOptionResult.DoNotWaitAfterMenuSelection);
                }
                // verifies selected Id is in list of users
                DisplayAccount verifiedAccount = accounts.Find(a => a.AccountId == accountToId);
                if (verifiedAccount != null)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Please provide a valid ID.");
                }
            }

            decimal transferAmount = GetDecimal("Enter amount: ");
            Account userAccount    = accountDAO.GetAccountByUserId(UserService.GetUserId());

            if (transferAmount > userAccount.Balance)
            {
                Console.WriteLine("I'm sorry you don't have enough funds for the transfer");
                return(MenuOptionResult.WaitAfterMenuSelection);
            }
            DisplayAccount toAccount = accounts.Find(a => a.AccountId == accountToId);
            Transfer       transfer  = new Transfer();

            transfer.TransferStatus = TransferStatus.Approved;
            transfer.TransferType   = TransferType.Send;
            transfer.AccountFrom    = userAccount.AccountId;
            transfer.AccountTo      = accountToId;
            transfer.Amount         = transferAmount;
            transfer.UserNameTo     = toAccount.Username;
            transfer.UserNameFrom   = UserService.GetUserName();

            bool wasTransferred = transferDAO.CreateTransfer(transfer);

            if (wasTransferred)
            {
                Console.WriteLine("Successful transfer!");
            }
            else
            {
                Console.WriteLine("Transfer failed.");
            }

            return(MenuOptionResult.WaitAfterMenuSelection);
        }
コード例 #4
0
 public List <AccountEntity> GetAllAccounts()
 {
     return(_accountDAO.GetAllAccounts());
 }