예제 #1
0
 //JDR: Get all loan request for spesific user
 public static ICollection <LoanRequest> GetLoanRequestsByUserID(int UserID)
 {
     using (BankDB db = new BankDB())
     {
         return(db.LoanRequest.OrderByDescending(Row => Row.ID).Where(Row => Row.UserID == UserID).ToList());
     }
 }
예제 #2
0
 public static User GetByEmail(string Email)
 {
     using (BankDB db = new BankDB())
     {
         User User = db.User.Where(Row => Row.Email == Email).FirstOrDefault();
         return(User);
     }
 }
예제 #3
0
        //JDR: Get LoanResults For spesific LoanRequest
        public LoanResult GetLoanResults()
        {
            using (BankDB db = new BankDB())
            {
                LoanResult Result = db.LoanResult.Where(Row => Row.RequestID == this.ID).FirstOrDefault();

                return(Result);
            }
        }
예제 #4
0
        public static bool EmailExist(string Email)
        {
            using (BankDB db = new BankDB())
            {
                var User = db.User.Where(userRow => userRow.Email == Email).FirstOrDefault();

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

                return(true);
            }
        }
예제 #5
0
        //JDR: OVERLOAD 3: Private method to set static user if ID found
        private static bool SetActiveUser(int UserID) //JDR: Use UserID for populating ActiveUser
        {
            using (BankDB db = new BankDB())
            {
                var activeUser = db.User.Find(UserID);

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

                UserAccount.SetActiveUser(activeUser);

                return(true);
            }
        }
예제 #6
0
        //JDR: Get user credit score
        public static CreditScore GetByUserID(int UserID)
        {
            using (BankDB db = new BankDB())
            {
                var CreditScore = db.CreditScore.
                                  OrderByDescending(Row => Row.ID).
                                  Where(Row => Row.UserID == UserID).
                                  FirstOrDefault();

                if (CreditScore == null)
                {
                    return(CreditScore.UpdateCreditScore(UserID));
                }

                return(CreditScore);
            }
        }
예제 #7
0
        public static bool Login(ref User user)
        {
            using (BankDB db = new BankDB())
            {
                string Email        = user.Email;
                string HashPassword = GLOBAL.Hash(user.Password, UserAccount.PasswordSalt);

                var activeUser = db.User.Where(userRow => userRow.Email == Email && userRow.Password == HashPassword).FirstOrDefault();

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

                user = activeUser;

                UserAccount.SetSession(activeUser);     //JDR: Store user login credentials in global Session
                UserAccount.SetActiveUser(activeUser);  //JDR: Set static variable for active user for all to call

                return(true);
            }
        }