public static bool SetUser(string username, string email, string type, string faculty, string password) { try { var userList = new List <User>(); userList = (from usr in _db.user where usr.name == username select usr).ToList(); if (userList.Count == 0) { User u = new User() { name = username, email = email, type = type, faculty = faculty, pwd = MySqlDataAccess.GetHash(password), }; try { _db.user.Add(u); _db.SaveChanges(); return(true); } catch { } } } catch { } return(false); }
public static bool GetUserIdentity(string username, string password) { String sql = "SELECT name,pwd FROM roadmap_db.user " + "where name='" + username + "' and pwd='" + MySqlDataAccess.GetHash(password) + "';"; string[] data = MySqlDataAccess.GetIdentity(sql); if (data[0] == username && data[1] == MySqlDataAccess.GetHash(password)) { return(true); } else { return(false); } }
public static bool IdentifyAdmin(string username, string password) { if (username == "Admin") { try { string[] userList = (from usr in _db.user where usr.name == "Admin" select usr.pwd).ToArray(); if (userList[0] == MySqlDataAccess.GetHash(password)) { return(true); } } catch { } } return(false); }