Example #1
0
        public dynamic UpdateBalance(TransactionDetail transactionDetail)
        {
            var sendacc = db.AccountDetails.Where(accnum => accnum.AccountNumber == transactionDetail.SenderAccount).FirstOrDefault();
            var receacc = db.AccountDetails.Where(accnum => accnum.AccountNumber == transactionDetail.RecieverAccount).FirstOrDefault();

            if (sendacc.AccountBalance >= transactionDetail.TransactionAmount)
            {
                sendacc.AccountBalance -= transactionDetail.TransactionAmount;
                receacc.AccountBalance += transactionDetail.TransactionAmount;
                db.SaveChanges();
            }
            else
            {
                return(err);
            }

            var transid = (from t in db.TransactionDetails
                           orderby t.TransactionID descending
                           select t.TransactionID).FirstOrDefault();

            return(transid);
        }
Example #2
0
 public void Add(TransactionDetail transactionDetail)
 {
     db.TransactionDetails.Add(transactionDetail);
     db.SaveChanges();
 }