public static bool UserExists(string username, string password) { try { var user = new User(); user = UserDL.AuthenticateUser(username, PasswordHash.MD5Hash(password)); if (user == null) { return(false); } else { return(true); } } catch (Exception ex) { throw ex; } }
public static UserModel AuthenticateUser(string username, string password) { try { var userObj = new UserModel(); var user = UserDL.AuthenticateUser(username, password); if (user != null) { var userFunctions = new List <FunctionModel>(); foreach (RoleFunction roleFunction in user.Role.RoleFunctions) { var function = new FunctionModel { Name = roleFunction.Function.Name, PageLink = roleFunction.Function.PageLink }; userFunctions.Add(function); } userObj.ID = user.ID; userObj.Username = user.Username; userObj.Role = user.Role.Name; userObj.Function = userFunctions; userObj.Branch = new BranchModel { ID = user.Branch.ID, Code = user.Branch.Code, Name = user.Branch.Name }; } return(userObj); } catch (Exception ex) { throw ex; } }