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 static List <Recommendation> GetAll() { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); List <Recommendation> resultList = new List <Recommendation>(); try { SqlDataReader reader = connection.Get(Networking.Shared.RequestConsts.Get.Recommendation.getAllRequest); while (reader.Read()) { int modelId = Convert.ToInt32(reader.GetValue(0)); int fabricId = Convert.ToInt32(reader.GetValue(1)); Independent.Model newModel = getModelById(modelId); SingleDependable.Fabric newFabric = getFabricById(fabricId); Recommendation newObject = new Recommendation(newModel, newFabric); resultList.Add(newObject); } } catch (SqlException exception) { Console.WriteLine(exception.Message); Console.WriteLine("ModelList is Empty"); } connection.closeConnection(); return(resultList); }
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 static List <Manufacturer> Get(string request) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); List <Manufacturer> resultList = new List <Manufacturer>(); try { SqlDataReader reader = connection.Get(request); while (reader.Read()) { int id = Convert.ToInt32(reader.GetValue(0)); string firmName = Convert.ToString(reader.GetValue(1)); string country = Convert.ToString(reader.GetValue(2)); Manufacturer newObject = new Manufacturer(id, firmName, country); resultList.Add(newObject); } } catch (SqlException exception) { Console.WriteLine(exception.Message); Console.WriteLine("ModelList is Empty"); } connection.closeConnection(); return(resultList); }
public static List <Client> Get(string request) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); List <Client> resultList = new List <Client>(); try { SqlDataReader reader = connection.Get(request); while (reader.Read()) { int id = Convert.ToInt32(reader.GetValue(0)); string fullName = Convert.ToString(reader.GetValue(1)); string phoneNumber = Convert.ToString(reader.GetValue(2)); string email = Convert.ToString(reader.GetValue(3)); Client newObject = new Client(id, fullName, phoneNumber, email); resultList.Add(newObject); } } catch (SqlException exception) { Console.WriteLine(exception.Message); Console.WriteLine("ModelList is Empty"); } connection.closeConnection(); return(resultList); }
public static List <Model> Get(string request) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); List <Model> resultList = new List <Model>(); try { SqlDataReader reader = connection.Get(request); while (reader.Read()) { int id = Convert.ToInt32(reader.GetValue(0)); string name = Convert.ToString(reader.GetValue(1)); double consumption = Convert.ToInt32(reader.GetValue(2)); double price = Convert.ToDouble(reader.GetValue(3)); string photoLink = Convert.ToString(reader.GetValue(4)); Model newObject = new Model(id, name, consumption, price, photoLink); resultList.Add(newObject); } } catch (SqlException exception) { Console.WriteLine(exception.Message); Console.WriteLine("ModelList is Empty"); } connection.closeConnection(); return(resultList); }
public static List <Cutter> Get(string request) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); List <Cutter> resultList = new List <Cutter>(); try { SqlDataReader reader = connection.Get(request); while (reader.Read()) { int id = Convert.ToInt32(reader.GetValue(0)); string fullName = Convert.ToString(reader.GetValue(1)); double salary = Convert.ToDouble(reader.GetValue(2)); int numberOfOrders = Convert.ToInt32(reader.GetValue(3)); Cutter newObject = new Cutter(id, fullName, salary, numberOfOrders); resultList.Add(newObject); } } catch (SqlException exception) { Console.WriteLine(exception.Message); Console.WriteLine("ModelList is Empty"); } connection.closeConnection(); return(resultList); }
public static List <Booking> Get(string request) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); List <Booking> resultList = new List <Booking>(); try { SqlDataReader reader = connection.Get(request); while (reader.Read()) { int id = Convert.ToInt32(reader.GetValue(0)); DateTime creationDate = DateTime.Parse(Convert.ToString(reader.GetValue(1))); DateTime issueDate = DateTime.Parse(Convert.ToString(reader.GetValue(2))); Mark isMarked = new Mark(Convert.ToString(reader.GetValue(3))); double bookingSum = Convert.ToDouble(reader.GetValue(4)); int cutterId = Convert.ToInt32(reader.GetValue(5)); int clientId = Convert.ToInt32(reader.GetValue(6)); int modelId = Convert.ToInt32(reader.GetValue(7)); int fabricId = Convert.ToInt32(reader.GetValue(8)); Independent.Cutter newCutter = getCutterById(cutterId); Independent.Client newClient = getClientById(clientId); Independent.Model newModel = getModelById(modelId); SingleDependable.Fabric newFabric = getFabricById(fabricId); Booking newObject = new Booking(id, creationDate, isMarked, issueDate, bookingSum, newCutter, newClient, newModel, newFabric); resultList.Add(newObject); } } catch (SqlException exception) { Console.WriteLine(exception.Message); Console.WriteLine("ModelList is Empty"); } connection.closeConnection(); return(resultList); }