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 void Delete(int id) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); string request = String.Format(Shared.RequestConsts.Delete.Fitting.deleteByIdRequest, id); connection.Insert(request); }
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 <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 <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 <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 <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 Client Add(string fullName, string phoneNumber, string email) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); string formattedPhoneNumber = phoneNumber.RemoveWhitespace(); string formattedEmail = email.RemoveWhitespace(); Client newClient = new Client(Services.IdBuilderService.GetRandomId(), fullName, phoneNumber, email); connection.Insert(String.Format(Shared.RequestConsts.Put.Independent.putClientRequest, newClient.id, fullName, formattedPhoneNumber, formattedEmail)); return(newClient); }
public static void Add(double bookingSum, int cutterId, int clientId, int modelId, int fabricId) { string issueDate = DateTime.Today.AddDays(7).ToString("MM/dd/yyyy"); Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); string bookingInsertRequest = String.Format(Shared.RequestConsts.Put.Dependable.putBookingRequest, DateTime.Today.ToString("MM/dd/yyyy"), issueDate, new Mark(false).ToString(), bookingSum, cutterId, clientId, modelId, fabricId); connection.Insert(bookingInsertRequest); }
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); }
public static void Add(Manufacturer manufacturer) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); connection.Insert(String.Format(Shared.RequestConsts.Put.Independent.putManufacturerRequest, manufacturer.id, manufacturer.firmName, manufacturer.country)); }
public static void Add(string request) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); connection.Insert(request); }
public static void UpdateLengthValueById(int id, double newValue) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); connection.Update(String.Format(Shared.RequestConsts.Update.Fabric.updateLenghtByIdRequest, newValue, id)); }
public static void Add(Fabric fabric) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); Independent.ManufacturerNetworkProxy.Add(fabric.manufacturer); connection.Insert(String.Format(Shared.RequestConsts.Put.Dependable.putFabricRequest, fabric.id, fabric.name, fabric.length, fabric.price, fabric.manufacturer.id, fabric.photoLink)); }
public static void Add(Networking.Independent.Model model, Networking.SingleDependable.Fabric fabric) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); connection.Insert(String.Format(Networking.Shared.RequestConsts.Put.Dependable.putRecomendationRequest, model.id, fabric.id)); }
public static void UpdateNumberOfOders(int id, int newValue) { Shared.SQLDatabaseConnetion connection = new Shared.SQLDatabaseConnetion(); connection.Update(String.Format(Shared.RequestConsts.Update.Cutter.updateNumOfOrdersByIdRequest, newValue, id)); }