/// <summary> /// Gets an assignment by its ID /// </summary> /// <param name="output"></param> /// <param name="id"></param> /// <returns></returns> public static bool FetchById(ref Assignment output, int id) { SQLiteDataReader reader = DBI.DoPreparedQuery( @"SELECT id, user, ship, role, start, COALESCE(until, -1) AS until FROM Assignment WHERE id = @id LIMIT 1;" , new Tuple <string, object>("@id", id)); if (reader != null && reader.Read()) { output = Assignment.Factory(reader); return(true); } return(false); }
/// <summary> /// Fetches the full assignment history of a user ordered from most /// recent to oldest /// </summary> /// <param name="output"></param> /// <param name="userId"></param> /// <returns></returns> public static bool FetchAssignmentHistory(ref List <Assignment> output, int userId) { output = new List <Assignment>(); SQLiteDataReader reader = DBI.DoPreparedQuery( @"SELECT id, user, ship, role, start, COALESCE(until, -1) AS until FROM Assignment WHERE user = @user ORDER BY start DESC;" , new Tuple <string, object>("@user", userId)); while (reader != null && reader.Read()) { Assignment a = Assignment.Factory(reader); output.Add(a); } return(true); }