public static UserProfile AuthorizeUser(String login, String password) { UserProfile profile = null; connection.Open(); command = new SQLiteCommand("SELECT * FROM 'User_Profile';", connection); reader = command.ExecuteReader(); while (reader.Read()) { if (reader["login"].ToString().Equals(login)) { if (reader["password"].ToString().Equals(password)) { string isAdmin = reader["isAdmin"].ToString(); Role role; if (isAdmin == "True") role = Role.ADMIN; else role = Role.STUDENT; int id = Convert.ToInt32(reader["user_id"].ToString()); profile = new UserProfile(login, password, role,id); } else { //login exists, password not exist! profile = new UserProfile(login, "", Role.STUDENT, 123); } } } if (profile == null) profile = new UserProfile("", "", Role.STUDENT, 123); connection.Close(); return profile; }
public static void RemoveUser(UserProfile user) { }
public static void RemoveUser(UserProfile user) { int id = user.userId; connection.Open(); command = new SQLiteCommand("DELETE from 'User_Profile' WHERE user_id=" + id.ToString(), connection); command.ExecuteNonQuery(); connection.Close(); }