Example #1
0
        public bool expValidate(DateTime transactdate)
        {
            cardInfoEntities db = new cardInfoEntities();
            var data            = db.CardInfoes.Where(x => x.expdate > transactdate).SingleOrDefault();

            if (data == null)
            {
                throw new ArgumentException("Invalid date");
            }
            else
            {
                return(true);
            }
        }
Example #2
0
        public bool cvvValidate(int cvv)
        {
            cardInfoEntities db = new cardInfoEntities();

            var data = db.CardInfoes.Where(x => x.cvvno == cvv).SingleOrDefault();

            if (data == null)
            {
                throw new ArgumentException("Invalid cvv");
            }
            else
            {
                return(true);
            }
        }
Example #3
0
        public int transaction(int transactamt)
        {
            cardInfoEntities db = new cardInfoEntities();
            CardInfo         ci = new CardInfo();
            var bal             = ci.balance;
            var data            = db.CardInfoes.Where(x => x.balance > transactamt);

            if (data == null)
            {
                throw new ArgumentException("Balance too low");
            }
            else
            {
                var olddata = db.CardInfoes.Where(x => x.balance > transactamt).SingleOrDefault();
                ci.balance      = ci.balance - transactamt;
                olddata.balance = ci.balance;
                Console.WriteLine("Balance sufficient for the transanction .Balance now is: " + ci.balance);
                var res = db.SaveChanges();
                return(Convert.ToInt16(ci.balance));
            }
        }