public bool Login(string userId, string userPass) { Email = userId; Password = userPass; try { if (Email != string.Empty && Password != string.Empty) { WealthDataContext oDc = new WealthDataContext(); tblUser user = oDc.tblUsers.FirstOrDefault(p => p.Email == this.Email); if (user != null) { tblUser user2 = oDc.tblUsers.FirstOrDefault(p => p.Password == this.GetHash()); if (user2 != null) { FirstName = user.FirstName; LastName = user.LastName; Password = user.Password; Email = user.Email; Id = user.Id; //set the app to the user CLogin.set(Id); return(true); } else { oDc = null; throw new Exception("Credentials are incorrect"); } } else { oDc = null; throw new Exception("User ID: " + Email + " could not be found"); } } else { throw new Exception("User ID and Password cannok be blank. Try again"); } } catch (Exception ex) { CErrorLog err = new CErrorLog(); err.LogError(ex.Message); throw ex; } }
public bool Login() { try { if (Email != string.Empty && Password != string.Empty) { WealthDataContext oDc = new WealthDataContext(); tblUser otblUser = oDc.tblUsers.FirstOrDefault(u => u.Email == Email); if (otblUser != null) { tblUser ouser = oDc.tblUsers.FirstOrDefault(u => u.Password == GetHash()); if (ouser != null) { FirstName = ouser.FirstName; LastName = ouser.LastName; Password = ouser.Password; Email = ouser.Email; Id = ouser.Id; //set the app to the user CLogin.set(Id); return(true); } else { oDc = null; throw new Exception("Password is incorrect"); } } else { oDc = null; throw new Exception("Email: " + Email + " could not be found"); } } else { throw new Exception("User ID and Password cannok be blank. Try again"); } } catch (Exception ex) { CErrorLog err = new CErrorLog(); err.LogError(ex.Message); throw ex; } }