//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()); } }
public static User GetByEmail(string Email) { using (BankDB db = new BankDB()) { User User = db.User.Where(Row => Row.Email == Email).FirstOrDefault(); return(User); } }
//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); } }
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); } }
//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); } }
//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); } }
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); } }