private IEnumerable <Tour> QueryToursFromDatabase(DbCommand command) { List <Tour> tourList = new List <Tour>(); using (IDataReader reader = database.ExecuteReader(command)) { while (reader.Read()) { if (reader["id"] != null) { Tour tmp = new Tour() { ID = (int)(long)reader["id"], Name = (string)reader["name"], Description = (string)reader["description"], StartLocation = (string)reader["startlocation"], EndLocation = (string)reader["endlocation"], MapImagePath = (string)reader["mapimagepath"], Distance = Convert.ToSingle(reader["distance"]) }; tourList.Add(tmp); } } } return(tourList); }
private IEnumerable <Log> QueryLogsFromDB(DbCommand command) { List <Log> loglist = new List <Log>(); using (IDataReader reader = database.ExecuteReader(command)) { while (reader.Read()) { loglist.Add(new Log() { ID = (int)reader["id"], Date = (string)reader["date"], Report = (string)reader["report"], Duration = (string)reader["duration"], Rating = (int)(long)reader["rating"], Steps = (int)(long)reader["steps"], Distance = (int)(long)reader["distance"], WeightKG = Convert.ToSingle(reader["weightkg"]), BloodPreassure = (string)reader["bloodpreassure"], Feeling = (string)reader["feeling"], Weather = (string)reader["feeling"], }); } } return(loglist); }