Example #1
0
        public bool Deposit(int id, decimal amount)
        {
            using (var ctx = new VirtualATMdbEntities1())
            {
                var transaction = new Transaction
                {
                    TransactionType = "Deposit",
                    AccountId       = id,
                    Amount          = (int)amount
                };
                ctx.Transaction.Add(transaction);

                ctx.Account.SingleOrDefault(e => e.AccountId == id).Balance += amount;

                return(ctx.SaveChanges() == 1);
            }
        }
Example #2
0
        public Account RetrieveBalance(int id)
        {
            var query = from a in db.Account
                        where a.AccountId == id
                        select a;

            foreach (var i in query)
            {
                var account = GetAccountById(id);
                var balance = account.Balance;
                balance = (decimal)balance;
            }
            return(query);

            using (var ctx = new VirtualATMdbEntities1())
            {
                return(ctx.Account.SingleOrDefault(a => a.AccountId == id));
            }
        }
Example #3
0
        public bool AuthenticateUser(int accountHolderId, int pin)
        {
            using (var ctx = new VirtualATMdbEntities1())
            {
                var holder = ctx
                             .AccountHolder
                             .SingleOrDefault(ah => ah.AccountHolderId == accountHolderId);

                if (holder == null)
                {
                    return(false);
                }

                if (holder.PIN == pin)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Example #4
0
 public IEnumerable <Transaction> TransactionActivity(int id)
 {
     using (var ctx = new VirtualATMdbEntities1())
     {
         var query =
             ctx
             .Transaction
             .Where(e => e.AccountId == id)
             .Select(
                 e =>
                 new Transaction
         {
             AccountId           = e.AccountId,
             TransactionId       = e.TransactionId,
             TransactionType     = e.TransactionType,
             TransactionDateTime = e.TransactionDateTime,
             Amount = e.Amount,
             TransactionDescription = e.TransactionDescription
         }
                 );
         return(query);
     }
 }