Ejemplo n.º 1
0
 public static double CheckBalance(string userName, string password, bool isCurrent)
 {
     using (MagDBEntities dbEntities = new MagDBEntities())
     {
         int id = dbEntities.UserDetails.Where(p => p.UserName == userName && p.Password == password).Select(p => p.Id).FirstOrDefault();
         if (id != null && id > 0)
         {
             double balance = dbEntities.AccountInformations.Where(p => p.UserId == id && p.IsCurrent==isCurrent).Select(p => p.Balance).FirstOrDefault();
             return balance;
         }
         else
         {
             return 0;
         }
     }
 }
Ejemplo n.º 2
0
        public static bool AddAccountDetails(string userName, string password,bool isCurrent)
        {
            using(MagDBEntities dbentities = new MagDBEntities())
            {
                UserDetail detail = new UserDetail();
                detail.UserName = userName;
                detail.Password=password;
                dbentities.UserDetails.Add(detail);
                dbentities.SaveChanges();

                AccountInformation info = new AccountInformation();
                info.IsCurrent=isCurrent;
                info.Balance=10000;
                info.UserId=detail.Id;
                dbentities.AccountInformations.Add(info);
                dbentities.SaveChanges();
                return true;
            }
        }
Ejemplo n.º 3
0
        public static bool CreditDebitAmount(int accountId, bool IsCredit, string balance)
        {
            using (MagDBEntities dbEntities = new MagDBEntities())
            {
                AccountInformation info = dbEntities.AccountInformations.Where(p => p.Id == accountId).FirstOrDefault();
                if (info != null)
                {
                    if (IsCredit)
                        info.Balance = info.Balance + Convert.ToDouble(balance);
                    else
                        info.Balance = info.Balance - Convert.ToDouble(balance);

                    dbEntities.SaveChanges();
                    return true
                        ;
                }
                else
                { return false; }
            }
        }