public static List <Fabric> Get(string request) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); List <Fabric> resultList = new List <Fabric>(); try { SqlDataReader reader = connection.Get(request); while (reader.Read()) { int id = Convert.ToInt32(reader.GetValue(0)); string name = Convert.ToString(reader.GetValue(1)); double length = Convert.ToDouble(reader.GetValue(2)); double price = Convert.ToDouble(reader.GetValue(3)); int manufacturerId = Convert.ToInt32(reader.GetValue(4)); string photoLink = Convert.ToString(reader.GetValue(5)); Independent.Manufacturer newManufacturer = getManufacturerById(manufacturerId); Fabric newObject = new Fabric(id, name, length, price, newManufacturer, photoLink); resultList.Add(newObject); } connection.closeConnection(); } catch (SqlException exception) { Console.WriteLine(exception.Message); Console.WriteLine("ModelList is Empty"); } return(resultList); }
public Fabric(int id, string name, double length, double price, Independent.Manufacturer manufacturer, string photoLink) { this.id = id; this.name = name; this.length = length; this.price = price; this.manufacturer = manufacturer; this.photoLink = photoLink; }