예제 #1
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;
            }
        }
예제 #2
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; }
            }
        }