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(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;
            }
        }
Example #3
0
 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()
 {
     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);
     }
 }
Example #5
0
        public static int PageCount(int boxPerPage = nuberBoxSetsPerPage)
        {
            CustomComputersAspEntities db = new CustomComputersAspEntities();
            int count = db.Configurations.Count() / boxPerPage;

            count += db.Configurations.Count() % boxPerPage > 0 ? 1 : 0;
            return(count);
        }
Example #6
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;
            }
        }
Example #7
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);
            }
        }
Example #8
0
 public static List<Configuration> ConfigurationOnPage(int pageNumber = 1, int boxSetsPerPage = nuberBoxSetsPerPage)
 {
     CustomComputersAspEntities db = new CustomComputersAspEntities();
     try
     {
         return db.Configurations.OrderBy(b => b.id).Skip((pageNumber - 1) * boxSetsPerPage).Take(boxSetsPerPage).ToList();
     }
     catch (Exception ex)
     {
         throw new ConfigurationDALException("Couldn't retrieve Configuration on page " + pageNumber, ex);
     }
 }
Example #9
0
 public static BoxSet GetBoxSetById(int id)
 {
     CustomComputersAspEntities db = new CustomComputersAspEntities();
     try
     {
         return db.BoxSets.FirstOrDefault(b => b.id == id);
     }
     catch (Exception ex)
     {
         throw new BoxSetDALException("Couldn't retrieve BoxSet with id = " + id, ex);
     }
 }
Example #10
0
 public static Cpu GetCpulById(int id)
 {
     CustomComputersAspEntities db = new CustomComputersAspEntities();
     try
     {
         return db.Cpus.FirstOrDefault(s => s.id == id);
     }
     catch (Exception ex)
     {
         throw new CpuDALException("Couldn't retrieve Cpu with id = " + id, ex);
     }
 }
Example #11
0
 public static Hdd GetHddlById(int id)
 {
     CustomComputersAspEntities db = new CustomComputersAspEntities();
     try
     {
         return db.Hdds.FirstOrDefault(s => s.id == id);
     }
     catch (Exception ex)
     {
         throw new HddDALException("Couldn't retrieve Hdd with id = " + id, ex);
     }
 }
Example #12
0
 public static Material GetMaterialById(int id)
 {
     CustomComputersAspEntities db = new CustomComputersAspEntities();
     try
     {
         return db.Materials.FirstOrDefault(s => s.id == id);
     }
     catch (Exception ex)
     {
         throw new MaterialDALException("Couldn't retrieve Materials with configid = " + id, ex);
     }
 }
Example #13
0
 public static Monitor GetMonitorById(int id)
 {
     CustomComputersAspEntities db = new CustomComputersAspEntities();
     try
     {
         return db.Monitors.FirstOrDefault(m => m.id == id);
     }
     catch (Exception ex)
     {
         throw new MonitorDALException("Couldn't retrieve monitor with id = " + id, ex);
     }
 }
Example #14
0
        public static VideoCard GetVideoCardlById(int id)
        {
            CustomComputersAspEntities db = new CustomComputersAspEntities();

            try
            {
                return(db.VideoCards.FirstOrDefault(s => s.id == id));
            }
            catch (Exception ex)
            {
                throw new VideoCardDALException("Couldn't retrieve VideoCard with id = " + id, ex);
            }
        }
Example #15
0
        public static BoxSet GetBoxSetById(int id)
        {
            CustomComputersAspEntities db = new CustomComputersAspEntities();

            try
            {
                return(db.BoxSets.FirstOrDefault(b => b.id == id));
            }
            catch (Exception ex)
            {
                throw new BoxSetDALException("Couldn't retrieve BoxSet with id = " + id, ex);
            }
        }
Example #16
0
        public static Monitor GetMonitorById(int id)
        {
            CustomComputersAspEntities db = new CustomComputersAspEntities();

            try
            {
                return(db.Monitors.FirstOrDefault(m => m.id == id));
            }
            catch (Exception ex)
            {
                throw new MonitorDALException("Couldn't retrieve monitor with id = " + id, ex);
            }
        }
Example #17
0
        public static Material GetMaterialById(int id)
        {
            CustomComputersAspEntities db = new CustomComputersAspEntities();

            try
            {
                return(db.Materials.FirstOrDefault(s => s.id == id));
            }
            catch (Exception ex)
            {
                throw new MaterialDALException("Couldn't retrieve Materials with configid = " + id, ex);
            }
        }
Example #18
0
        public static IQueryable <Software> GetSoftwareByConfigId(int id)
        {
            CustomComputersAspEntities db = new CustomComputersAspEntities();

            try
            {
                return(db.Softwares.Where(s => s.configId == id));
            }
            catch (Exception ex)
            {
                throw new PeripheralDALException("Couldn't retrieve Software with configid = " + id, ex);
            }
        }
Example #19
0
        public static List <Peripheral> GetPeripheralsByConfigId(int id)
        {
            CustomComputersAspEntities db = new CustomComputersAspEntities();

            try
            {
                return(db.Peripherals.Where(p => p.configId == id).ToList());
            }
            catch (Exception ex)
            {
                throw new PeripheralDALException("Couldn't retrieve Peripherals with configid = " + id, ex);
            }
        }
Example #20
0
        public static List <Configuration> ConfigurationOnPage(int pageNumber = 1, int boxSetsPerPage = nuberBoxSetsPerPage)
        {
            CustomComputersAspEntities db = new CustomComputersAspEntities();

            try
            {
                return(db.Configurations.OrderBy(b => b.id).Skip((pageNumber - 1) * boxSetsPerPage).Take(boxSetsPerPage).ToList());
            }
            catch (Exception ex)
            {
                throw new ConfigurationDALException("Couldn't retrieve Configuration on page " + pageNumber, ex);
            }
        }
Example #21
0
        public static Cpu GetCpulById(int id)
        {
            CustomComputersAspEntities db = new CustomComputersAspEntities();

            try
            {
                return(db.Cpus.FirstOrDefault(s => s.id == id));
            }
            catch (Exception ex)
            {
                throw new CpuDALException("Couldn't retrieve Cpu with id = " + id, ex);
            }
        }
Example #22
0
        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();
            }
        }
Example #23
0
        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();
            }
        }
Example #24
0
 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();
     }
 }
Example #25
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;
 }
Example #26
0
 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();
     }
 }
Example #27
0
 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();
     }
 }
Example #28
0
        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();
            }
        }
Example #29
0
        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();
            }
        }
Example #30
0
        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();
            }
        }
Example #31
0
        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();
            }
        }
Example #32
0
 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();
     }
 }
Example #33
0
        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();
            }
        }
Example #34
0
        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();
            }
        }
Example #35
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);
        }
Example #36
0
        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);
        }
Example #37
0
        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);
        }
Example #38
0
        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);
        }
Example #39
0
        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();
            }
        }
Example #40
0
 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();
     }
 }
Example #41
0
        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;
        }
Example #42
0
 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();
     }
 }
Example #43
0
        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;
        }
Example #44
0
 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();
     }
 }
Example #45
0
 public static List<Peripheral> GetPeripheralsByConfigId(int id)
 {
     CustomComputersAspEntities db = new CustomComputersAspEntities();
     try
     {
         return db.Peripherals.Where(p => p.configId == id).ToList();
     }
     catch (Exception ex)
     {
         throw new PeripheralDALException("Couldn't retrieve Peripherals with configid = " + id, ex);
     }
 }
Example #46
0
        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;
        }
Example #47
0
 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();
     }
 }
Example #48
0
 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();
     }
 }
Example #49
0
 public static IQueryable<Software> GetSoftwareByConfigId(int id)
 {
     CustomComputersAspEntities db = new CustomComputersAspEntities();
     try
     {
         return db.Softwares.Where(s => s.configId == id);
     }
     catch (Exception ex)
     {
         throw new PeripheralDALException("Couldn't retrieve Software with configid = " + id, ex);
     }
 }
Example #50
0
 public static int PageCount(int boxPerPage = nuberBoxSetsPerPage)
 {
     CustomComputersAspEntities db = new CustomComputersAspEntities();
     int count = db.Configurations.Count() / boxPerPage;
     count += db.Configurations.Count() % boxPerPage > 0 ? 1 : 0;
     return count;
 }