public int PopulateDatabase() { try { CustomComputersAspEntities db = new CustomComputersAspEntities(); int materialsid = this.InsertMaterials(); string producerMonitor = this.monitor.GetMonitorProducer(); string ledMonitor = this.monitor.GetLed(); string aspectRatioMonitor = this.monitor.GetAspecRatio().Item1.ToString() + "x" + this.monitor.GetAspecRatio().Item2.ToString(); string matrixMonitor = this.monitor.GetMatrixAndMatrixProducer().Item1; Monitor match = db.Monitors.FirstOrDefault(m => m.led == ledMonitor && m.aspectRatio == aspectRatioMonitor && m.producer == producerMonitor && m.matrix == matrixMonitor && m.materialsId == materialsid); if (match == null) { db.AddToMonitors(new Monitor() { led = ledMonitor, aspectRatio = aspectRatioMonitor, producer = producerMonitor, materialsId = materialsid, matrix = matrixMonitor }); db.SaveChanges(); match = db.Monitors.FirstOrDefault(m => m.led == ledMonitor && m.aspectRatio == aspectRatioMonitor && m.producer == producerMonitor && m.matrix == matrixMonitor && m.materialsId == materialsid); } return match.id; } catch (Exception ex) { Console.WriteLine("Could not successfully populate DB with monitor information. Reason: {0}", ex.Message); return 0; } }
public int PopulateDataBase(int boxId, int monitorId) { try { CustomComputersAspEntities db = new CustomComputersAspEntities(); Configuration match = db.Configurations.FirstOrDefault(c => c.boxId == boxId && c.monitorId == monitorId); if (match == null) { db.AddToConfigurations(new Configuration() { boxId = boxId, monitorId = monitorId }); db.SaveChanges(); match = db.Configurations.FirstOrDefault(c => c.boxId == boxId && c.monitorId == monitorId); } return match.id; } catch (Exception ex) { Console.WriteLine("Could not successfully populate DataBase with Configuration. Reason: {0}", ex.Message); return 0; } }
public int PopulateDataBase() { try { int cpuId = this.InsertCpu(); int videoId = this.InsertVideoCard(); int hddId = this.InsertHdd(); string motherBoard = this.boxSet.GetMotherBoard(); string ram = this.boxSet.GetRam(); string coolSys = this.boxSet.GetCoolingSystem(); string soundCard = this.boxSet.GetSoundCard(); string powerSupply = this.boxSet.GetPowerSupply(); string expansionCard = this.boxSet.GetExpansionCard(); string box = this.boxSet.GetBox(); string usb = this.boxSet.GetRemovableDevices().Item1; string disk = this.boxSet.GetRemovableDevices().Item2; string cardReader = this.boxSet.GetRemovableDevices().Item3; string removableDev = usb + "; " + disk + "; " + cardReader; CustomComputersAspEntities db = new CustomComputersAspEntities(); BoxSet match = db.BoxSets.FirstOrDefault(b => b.cupId == cpuId && b.videoCardId == videoId && b.hddId == hddId && b.motherboard == motherBoard && b.ram == ram && b.coolingSystem == coolSys && b.powerSupply == powerSupply && b.expansionCards == expansionCard && b.box == box && b.removableDevices == removableDev); if (match == null) { db.AddToBoxSets(new BoxSet() { cupId = cpuId, videoCardId = videoId, hddId = hddId, motherboard = motherBoard, ram = ram, coolingSystem = coolSys, powerSupply = powerSupply, expansionCards = expansionCard, box = box, removableDevices = removableDev, }); db.SaveChanges(); match = db.BoxSets.FirstOrDefault(b => b.cupId == cpuId && b.videoCardId == videoId && b.hddId == hddId && b.motherboard == motherBoard && b.ram == ram && b.coolingSystem == coolSys && b.powerSupply == powerSupply && b.expansionCards == expansionCard && b.box == box && b.removableDevices == removableDev); } return(match.id); } catch (Exception ex) { Console.WriteLine("Could not successsfully populate DataBase with BoxSet. Reason: {0}", ex.Message); return(0); } }
public int PopulateDataBase() { try { int cpuId = this.InsertCpu(); int videoId = this.InsertVideoCard(); int hddId = this.InsertHdd(); string motherBoard = this.boxSet.GetMotherBoard(); string ram = this.boxSet.GetRam(); string coolSys = this.boxSet.GetCoolingSystem(); string soundCard = this.boxSet.GetSoundCard(); string powerSupply = this.boxSet.GetPowerSupply(); string expansionCard = this.boxSet.GetExpansionCard(); string box = this.boxSet.GetBox(); string usb = this.boxSet.GetRemovableDevices().Item1; string disk = this.boxSet.GetRemovableDevices().Item2; string cardReader = this.boxSet.GetRemovableDevices().Item3; string removableDev = usb + "; " + disk + "; " + cardReader; CustomComputersAspEntities db = new CustomComputersAspEntities(); BoxSet match = db.BoxSets.FirstOrDefault(b => b.cupId == cpuId && b.videoCardId == videoId && b.hddId == hddId && b.motherboard == motherBoard && b.ram == ram && b.coolingSystem == coolSys && b.powerSupply == powerSupply && b.expansionCards == expansionCard && b.box == box && b.removableDevices == removableDev); if (match == null) { db.AddToBoxSets(new BoxSet() { cupId = cpuId, videoCardId = videoId, hddId = hddId, motherboard = motherBoard, ram = ram, coolingSystem = coolSys, powerSupply = powerSupply, expansionCards = expansionCard, box = box, removableDevices = removableDev, }); db.SaveChanges(); match = db.BoxSets.FirstOrDefault(b => b.cupId == cpuId && b.videoCardId == videoId && b.hddId == hddId && b.motherboard == motherBoard && b.ram == ram && b.coolingSystem == coolSys && b.powerSupply == powerSupply && b.expansionCards == expansionCard && b.box == box && b.removableDevices == removableDev); } return match.id; } catch (Exception ex) { Console.WriteLine("Could not successsfully populate DataBase with BoxSet. Reason: {0}",ex.Message); return 0; } }
private int InsertMaterials() { CustomComputersAspEntities db = new CustomComputersAspEntities(); string standmaterial = this.monitor.GetMaterials().Item1; string displaymaterial = this.monitor.GetMaterials().Item2; Material match = db.Materials.FirstOrDefault(x => x.stand == standmaterial && x.display == displaymaterial); if (match == null) { db.AddToMaterials(new Material() { stand = standmaterial, display = displaymaterial }); db.SaveChanges(); } match = db.Materials.FirstOrDefault(x => x.stand == standmaterial && x.display == displaymaterial); return match.id; }
private void InsertAntivirus() { string antiVirus = this.software.GetAntiVirusAndProducer().Item1; string antiVirusProducer = this.software.GetAntiVirusAndProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Softwares.FirstOrDefault(s => s.name == antiVirus && s.producer == antiVirusProducer && s.configId == this.configId); if (match == null) { db.AddToSoftwares(new Software() { name = antiVirus, producer = antiVirusProducer, type = "antiVirus", configId = this.configId }); db.SaveChanges(); } }
private void InsertVideoCamera() { string videoCamera = this.peripheral.GetVideoCamera(); CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == videoCamera && p.configId == this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = videoCamera, producer = "", type = "videoCamera", configId = this.configId }); db.SaveChanges(); } }
private void InsertOtherDevices() { string otherDevices = this.peripheral.GetOtherDevices(); CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == otherDevices && p.configId == this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = otherDevices, producer = "", type = "otherDevices", configId = this.configId }); db.SaveChanges(); } }
private void InsertMicrophone() { string microphone = this.peripheral.GetMicrophone(); CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == microphone && p.configId == this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = microphone, producer = "", type = "microphone", configId = this.configId }); db.SaveChanges(); } }
private void InsertKeyBoard() { string keyBoardName = this.peripheral.GetKeyBoardAndKeyboardProducer().Item1; string producerName = this.peripheral.GetKeyBoardAndKeyboardProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == keyBoardName && p.producer == producerName && p.configId==this.configId); if(match==null) { db.AddToPeripherals(new Peripheral() { name = keyBoardName, producer = producerName, type = "keyoard", configId = this.configId }); db.SaveChanges(); } }
private void InsertHeadphones() { string headphonesName = this.peripheral.GetHeadphonesAndHeadphoneProducer().Item1; string producerName = this.peripheral.GetHeadphonesAndHeadphoneProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == headphonesName && p.producer == producerName && p.configId==this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = headphonesName, producer = producerName, type = "headphones", configId = this.configId }); db.SaveChanges(); } }
private void InsertKeyBoard() { string keyBoardName = this.peripheral.GetKeyBoardAndKeyboardProducer().Item1; string producerName = this.peripheral.GetKeyBoardAndKeyboardProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == keyBoardName && p.producer == producerName && p.configId == this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = keyBoardName, producer = producerName, type = "keyoard", configId = this.configId }); db.SaveChanges(); } }
private void InsertMouse() { string mousename = this.peripheral.GetMouseAndMouesProducer().Item1; string producername = this.peripheral.GetMouseAndMouesProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == mousename && p.producer == producername && p.configId == this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = mousename, producer = producername, type = "mouse", configId = this.configId }); db.SaveChanges(); } }
private void InsertHeadphones() { string headphonesName = this.peripheral.GetHeadphonesAndHeadphoneProducer().Item1; string producerName = this.peripheral.GetHeadphonesAndHeadphoneProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == headphonesName && p.producer == producerName && p.configId == this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = headphonesName, producer = producerName, type = "headphones", configId = this.configId }); db.SaveChanges(); } }
private void InsertOther() { string other = this.software.GetOther().Item1; string otherProducer = this.software.GetOther().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Softwares.FirstOrDefault(s => s.name == other && s.producer == otherProducer && s.configId == this.configId); if (match == null) { db.AddToSoftwares(new Software() { name = other, producer = otherProducer, type = "other", configId = this.configId }); db.SaveChanges(); } }
private int InsertVideoCard() { string video = this.boxSet.GetVideoCardAndVideoCardProducer().Item1; string videoProducer = this.boxSet.GetVideoCardAndVideoCardProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); VideoCard match = db.VideoCards.FirstOrDefault(v => v.name == video && v.producer == videoProducer); if (match == null) { db.AddToVideoCards(new VideoCard() { name = video, producer = videoProducer }); db.SaveChanges(); match = db.VideoCards.FirstOrDefault(v => v.name == video && v.producer == videoProducer); } return(match.id); }
private int InsertCpu() { string cpu = this.boxSet.GetCpuAndCpuProducer().Item1; string cpuProducer = this.boxSet.GetCpuAndCpuProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); Cpu match = db.Cpus.FirstOrDefault(c => c.name == cpu && c.producer == cpuProducer); if (match == null) { db.AddToCpus(new Cpu() { name = cpu, producer = cpuProducer }); db.SaveChanges(); match = db.Cpus.FirstOrDefault(c => c.name == cpu && c.producer == cpuProducer); } return(match.id); }
private int InsertHdd() { string hdd = this.boxSet.GetHddAndHddProducer().Item1; string hddProducer = this.boxSet.GetHddAndHddProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); Hdd match = db.Hdds.FirstOrDefault(h => h.name == hdd && h.producer == hddProducer); if (match == null) { db.AddToHdds(new Hdd() { name = hdd, producer = hddProducer }); db.SaveChanges(); match = db.Hdds.FirstOrDefault(h => h.name == hdd && h.producer == hddProducer); } return(match.id); }
private void InsertGame(int gameNumber) { int newGameNumber = gameNumber - 1; string game = this.software.GetGameAndProducer(newGameNumber).Item1; string gameProducer = this.software.GetGameAndProducer(newGameNumber).Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Softwares.FirstOrDefault(s => s.name == game && s.producer == gameProducer && s.configId == this.configId); if (match == null) { db.AddToSoftwares(new Software() { name = game, producer = gameProducer, type = "game", configId = this.configId }); db.SaveChanges(); } }
private void InsertMouse() { string mousename = this.peripheral.GetMouseAndMouesProducer().Item1; string producername = this.peripheral.GetMouseAndMouesProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == mousename && p.producer == producername && p.configId==this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = mousename, producer = producername, type = "mouse", configId = this.configId }); db.SaveChanges(); } }
private void InsertVideoCamera() { string videoCamera = this.peripheral.GetVideoCamera(); CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == videoCamera && p.configId==this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = videoCamera, producer = "", type = "videoCamera", configId = this.configId }); db.SaveChanges(); } }
private void InsertGame(int gameNumber) { int newGameNumber = gameNumber - 1; string game = this.software.GetGameAndProducer(newGameNumber).Item1; string gameProducer = this.software.GetGameAndProducer(newGameNumber).Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Softwares.FirstOrDefault(s => s.name == game && s.producer == gameProducer && s.configId == this.configId); if(match == null) { db.AddToSoftwares(new Software() { name = game, producer = gameProducer, type = "game", configId = this.configId }); db.SaveChanges(); } }
private void InsertMicrophone() { string microphone = this.peripheral.GetMicrophone(); CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == microphone && p.configId==this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = microphone, producer = "", type = "microphone", configId = this.configId }); db.SaveChanges(); } }
private void InsertOtherDevices() { string otherDevices = this.peripheral.GetOtherDevices(); CustomComputersAspEntities db = new CustomComputersAspEntities(); var match = db.Peripherals.FirstOrDefault(p => p.name == otherDevices && p.configId==this.configId); if (match == null) { db.AddToPeripherals(new Peripheral() { name = otherDevices, producer = "", type = "otherDevices", configId = this.configId }); db.SaveChanges(); } }
private int InsertHdd() { string hdd = this.boxSet.GetHddAndHddProducer().Item1; string hddProducer = this.boxSet.GetHddAndHddProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); Hdd match = db.Hdds.FirstOrDefault(h => h.name == hdd && h.producer == hddProducer); if (match == null) { db.AddToHdds(new Hdd() { name = hdd, producer = hddProducer }); db.SaveChanges(); match = db.Hdds.FirstOrDefault(h => h.name == hdd && h.producer == hddProducer); } return match.id; }
private int InsertVideoCard() { string video = this.boxSet.GetVideoCardAndVideoCardProducer().Item1; string videoProducer = this.boxSet.GetVideoCardAndVideoCardProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); VideoCard match = db.VideoCards.FirstOrDefault(v => v.name == video && v.producer == videoProducer); if (match == null) { db.AddToVideoCards(new VideoCard() { name = video, producer = videoProducer }); db.SaveChanges(); match = db.VideoCards.FirstOrDefault(v => v.name == video && v.producer == videoProducer); } return match.id; }
private int InsertCpu() { string cpu = this.boxSet.GetCpuAndCpuProducer().Item1; string cpuProducer = this.boxSet.GetCpuAndCpuProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); Cpu match = db.Cpus.FirstOrDefault(c => c.name == cpu && c.producer == cpuProducer); if (match == null) { db.AddToCpus(new Cpu() { name = cpu, producer = cpuProducer }); db.SaveChanges(); match = db.Cpus.FirstOrDefault(c => c.name == cpu && c.producer == cpuProducer); } return match.id; }