public static List <Fitting> Get(string request) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); List <Fitting> resultList = new List <Fitting>(); try { SqlDataReader reader = connection.Get(request); while (reader.Read()) { int id = Convert.ToInt32(reader.GetValue(0)); int bookingId = Convert.ToInt32(reader.GetValue(1)); string comment = Convert.ToString(reader.GetValue(2)); MultipleDependable.Booking newBooking = getBookingById(bookingId); Fitting newObject = new Fitting(id, comment, newBooking); resultList.Add(newObject); } } catch (SqlException exception) { Console.WriteLine(exception.Message); Console.WriteLine("ModelList is Empty"); } connection.closeConnection(); return(resultList); }
public Fitting(int id, string comment, MultipleDependable.Booking booking) { this.id = id; this.comment = comment; this.booking = booking; }