Ejemplo n.º 1
0
        public static IQueryable <tbSaving> QueryUserAccount(Guid customerId, int index)
        {
            var db = new dbBankEntities();

            return(from users in db.tbSavings
                   where users.Customer_Id == customerId && users.SavingId == index
                   select users);
        }
Ejemplo n.º 2
0
        public static void SaveCustomer(BankDTO.CustomerDTO createdCustomer)
        {
            var db = new dbBankEntities();

            var newCustomer = setCustomerInfo(createdCustomer);

            db.tbCustomers.Add(newCustomer);
            db.SaveChanges();
        }
Ejemplo n.º 3
0
        private static List <AccountDTO> QueryFindAccount(CustomerDTO userInfo)
        {
            var db = new dbBankEntities();

            var account = from saving in db.tbSavings
                          where saving.Customer_Id == userInfo.CustomerId
                          select saving;

            return(ConvertQueryToList(account));
        }
Ejemplo n.º 4
0
 public static tbCustomer QueryFindUser(CustomerDTO userLogin)
 {
     using (var db = new dbBankEntities())
     {
         return((from cust in db.tbCustomers
                 where cust.Username == userLogin.Username &&
                 cust.Password == userLogin.Password
                 select cust).SingleOrDefault());
     }
 }
Ejemplo n.º 5
0
        public static void DeleteRow(int index, Guid customerId)
        {
            var db = new dbBankEntities();

            var deleteSelectedRow = (from account in db.tbSavings
                                     where account.Customer_Id == customerId && account.SavingId == index
                                     select account).FirstOrDefault();

            db.tbSavings.Remove(deleteSelectedRow);
            db.SaveChanges();
        }
Ejemplo n.º 6
0
        public static List <AccountDTO> SelectedAccount(string accountValue)
        {
            var db        = new dbBankEntities();
            int accountId = int.Parse(accountValue);

            IQueryable <tbSaving> selectedAccounts = from accounts in db.tbSavings
                                                     where accounts.SavingId == accountId
                                                     select accounts;

            var selectedAccount = ValidateDb.ConvertQueryToList(selectedAccounts);

            return(selectedAccount);
        }
Ejemplo n.º 7
0
        public static bool IsExisting(CustomerDTO createdCustomer)
        {
            var db = new dbBankEntities();

            foreach (var customer in db.tbCustomers)
            {
                if (customer.Username == createdCustomer.Username)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 8
0
        private static string CreateNewRoutingNumber(Random random, dbBankEntities db)
        {
            string newRoutingNumber;

            IQueryable <tbSaving> queryRoutingMatches = null;

            do
            {
                newRoutingNumber    = RandomGenerator(random);
                queryRoutingMatches = FindRoutingMatches(db, newRoutingNumber);
            } while (CheckingRouting(queryRoutingMatches) == false);

            return(newRoutingNumber);
        }
Ejemplo n.º 9
0
        public static void CreateAccount(Guid customerId, decimal amount)
        {
            var db = new dbBankEntities();

            Random random     = new Random();
            var    newAccount = new tbSaving();

            newAccount.Customer_Id   = customerId;
            newAccount.RoutingNumber = CreateNewRoutingNumber(random, db);
            newAccount.AccountNumber = CreateNewAccountNumber(random);
            newAccount.Amount        = amount;

            db.tbSavings.Add(newAccount);
            db.SaveChanges();
        }
Ejemplo n.º 10
0
        public static void StoreChange(AccountDTO _changedAccount)
        {
            var db = new dbBankEntities();

            var queryDbAmount = (from account in db.tbSavings
                                 where account.SavingId == _changedAccount.SavingId
                                 select account).FirstOrDefault();

            queryDbAmount.Amount = _changedAccount.Amount;

            /*var changedAccount = new tbSaving();
             * changedAccount.AccountNumber = _changedAccount.AccountNumber;
             * changedAccount.Amount = _changedAccount.Amount;
             * changedAccount.Customer_Id = _changedAccount.Customer_Id;
             * changedAccount.RoutingNumber = _changedAccount.RoutingNumber;
             * changedAccount.SavingId = _changedAccount.SavingId;
             *
             * db.tbSavings.Remove(queryDbAmount);
             * db.tbSavings.Add(changedAccount);*/
            db.SaveChanges();
        }
Ejemplo n.º 11
0
 private static IQueryable <tbSaving> FindRoutingMatches(dbBankEntities db, string newRoutingNumber)
 {
     return(from accounts in db.tbSavings
            where accounts.RoutingNumber == newRoutingNumber
            select accounts);
 }