Exemplo n.º 1
0
        public async Task <IActionResult> LoadCoolers()
        {
            ViewData["HwType"] = "Cooler";

            string moboID = HttpContext.Session.GetString(SessionKeyMOBO);
            MOBO   mobo   = null;

            if (!String.IsNullOrEmpty(moboID))
            {
                mobo = await _context.MOBOes.SingleOrDefaultAsync(m => m.Id == Int32.Parse(moboID));
            }

            string cpuID = HttpContext.Session.GetString(SessionKeyCPU);
            CPU    cpu   = null;

            if (!String.IsNullOrEmpty(cpuID))
            {
                cpu = await _context.CPUs.SingleOrDefaultAsync(m => m.Id == Int32.Parse(cpuID));
            }

            List <Cooler> coolerList = await _context.Coolers.AsNoTracking().ToListAsync();

            List <CoolerViewModel> coolerListValidated = new List <CoolerViewModel>();

            foreach (var item in coolerList)
            {
                CoolerViewModel coolerValidated = new CoolerViewModel
                {
                    Cooler    = item,
                    Socket_ok = true
                };

                if (mobo != null)
                {
                    if (!item.Socket.Equals(mobo.Socket))
                    {
                        coolerValidated.Socket_ok = false;
                    }
                }
                if (cpu != null)
                {
                    if (!item.Socket.Equals(cpu.Socket))
                    {
                        coolerValidated.Socket_ok = false;
                    }
                }

                coolerListValidated.Add(coolerValidated);
            }

            return(View("Coolers", coolerListValidated));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts a MySQL query result into a Computer
        /// </summary>
        /// <param name="result">The MySQL query result</param>
        /// <returns>The Computer found from the query</returns>
        public static Computer GetFromQuery(string result)
        {
            string[]     arr     = result.Split('\0');
            CPU          cpu     = CPU.Get(int.Parse(arr[2]));
            Fan          fan     = Fan.Get(int.Parse(arr[3]));
            GraphicsCard gCard   = GraphicsCard.Get(int.Parse(arr[4]));
            Memory       memory  = Memory.Get(int.Parse(arr[5]));
            MOBO         mBoard  = MOBO.Get(int.Parse(arr[6]));
            Case         c       = Case.Get(int.Parse(arr[7]));
            PowerSupply  power   = PowerSupply.Get(int.Parse(arr[8]));
            Storage      storage = Storage.Get(int.Parse(arr[9]));

            return(new Computer(int.Parse(arr[0]), arr[1], c, cpu, fan, gCard, memory, mBoard, power, storage));
        }
Exemplo n.º 3
0
        /// <summary>
        /// action that occurs when the user chooses a part type. will set the collection/datasource of the part dropdown menu to those that match
        /// the users selection. will also populate the description box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void partTypeBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            String test = partTypeBox.SelectedItem.ToString();

            Queries.Log(Queries.LogLevel.DEBUG, "Selected : " + test);
            string attribs = "";

            if (test == "CPU")
            {
                partBox.DataSource = CPU.GetAll();
                attribs            = ((CPU)partBox.SelectedItem).GetAttributes();
            }
            else if (test == "Cooling")
            {
                partBox.DataSource = Fan.GetAll();
                attribs            = ((Fan)partBox.SelectedItem).GetAttributes();
            }
            else if (test == "Case")
            {
                partBox.DataSource = Case.GetAll();
                attribs            = ((Case)partBox.SelectedItem).GetAttributes();
            }
            else if (test == "Memory")
            {
                partBox.DataSource = Memory.GetAll();
                attribs            = ((Memory)partBox.SelectedItem).GetAttributes();
            }
            else if (test == "Power Supply")
            {
                partBox.DataSource = PowerSupply.GetAll();
                attribs            = ((PowerSupply)partBox.SelectedItem).GetAttributes();
            }
            else if (test == "Storage")
            {
                partBox.DataSource = Storage.GetAll();
                attribs            = ((Storage)partBox.SelectedItem).GetAttributes();
            }
            else if (test == "Graphics Card")
            {
                partBox.DataSource = GraphicsCard.GetAll();
                attribs            = ((GraphicsCard)partBox.SelectedItem).GetAttributes();
            }
            else if (test == "Motherboard")
            {
                partBox.DataSource = MOBO.GetAll();
                attribs            = ((MOBO)partBox.SelectedItem).GetAttributes();
            }
            partDescriptionBox.Text = attribs;
            priceTxtBox.Text        = "$" + ((Part)partBox.SelectedItem).price;
        }
Exemplo n.º 4
0
        public void AddConfiguration(CPU cpu, GPU gpu, MOBO mobo, RAM ram, PSU psu, Case casePC, Cooler cooler, ApplicationUser user)
        {
            PC pcdata = new PC();

            pcdata.CPU             = cpu;
            pcdata.GPU             = gpu;
            pcdata.MOBO            = mobo;
            pcdata.RAM             = ram;
            pcdata.PSU             = psu;
            pcdata.Case            = casePC;
            pcdata.Cooler          = cooler;
            pcdata.ApplicationUser = user;
            _context.PCs.Add(pcdata);
            _context.SaveChanges();
        }
Exemplo n.º 5
0
        public async Task <IActionResult> LoadRAMs()
        {
            ViewData["HwType"] = "RAM";

            string moboID = HttpContext.Session.GetString(SessionKeyMOBO);
            MOBO   mobo   = null;

            if (!String.IsNullOrEmpty(moboID))
            {
                mobo = await _context.MOBOes.SingleOrDefaultAsync(m => m.Id == Int32.Parse(moboID));
            }

            List <RAM> ramList = await _context.RAMs.AsNoTracking().ToListAsync();

            List <RAMViewModel> ramListValidated = new List <RAMViewModel>();

            foreach (var item in ramList)
            {
                RAMViewModel ramValidated = new RAMViewModel
                {
                    RAM         = item,
                    Ram_type_ok = true
                };

                if (mobo != null)
                {
                    if (!item.Ram_type.Equals(mobo.Ram_type))
                    {
                        ramValidated.Ram_type_ok = false;
                    }
                }

                ramListValidated.Add(ramValidated);
            }

            return(View("RAMs", ramListValidated));
        }
Exemplo n.º 6
0
        public static void Initialize(ApplicationDbContext context)
        {
            context.Database.EnsureCreated();
            if (context.CPUs.Any())
            {
                return;   // DB has been seeded
            }
            // CPU
            var CPUs = new CPU[]
            {
                new CPU
                {
                    Name         = "i5-8400",
                    Manufacturer = "Intel",
                    Series       = "i5",
                    Socket       = "1151",
                    Cores        = "6",
                    TDP          = "65",
                    iGPU         = 1,
                    Price        = "829"
                },
                new CPU
                {
                    Name         = "Ryzen 5 1600",
                    Manufacturer = "AMD",
                    Series       = "Ryzen 5",
                    Socket       = "AM4",
                    Cores        = "6",
                    TDP          = "65",
                    iGPU         = 0,
                    Price        = "899"
                },
                new CPU
                {
                    Name         = "Ryzen 7 1700",
                    Manufacturer = "AMD",
                    Series       = "Ryzen 7",
                    Socket       = "AM4",
                    Cores        = "8",
                    TDP          = "95",
                    iGPU         = 0,
                    Price        = "1299"
                },
                new CPU
                {
                    Name         = "i7-8600",
                    Manufacturer = "Intel",
                    Series       = "i7",
                    Socket       = "1151",
                    Cores        = "6",
                    TDP          = "95",
                    iGPU         = 1,
                    Price        = "1459"
                }
            };

            foreach (CPU c in CPUs)
            {
                context.CPUs.Add(c);
            }
            context.SaveChanges();



            //MOBO

            var Moboes = new MOBO[] {
                new MOBO
                {
                    Name         = "Z370-A PRO",
                    Manufacturer = "MSI",
                    Standard     = "ATX",
                    Chipset      = "Z370",
                    Socket       = "1151",
                    Ram_type     = "DDR4",
                    Price        = "519"
                },
                new MOBO
                {
                    Name         = "MSI B350 TOMAHAWK",
                    Manufacturer = "MSI",
                    Standard     = "ATX",
                    Chipset      = "B350",
                    Socket       = "AM4",
                    Ram_type     = "DDR4",
                    Price        = "384"
                },
                new MOBO
                {
                    Name         = "ASUS PRIME X370 PRO",
                    Manufacturer = "ASUS",
                    Standard     = "ATX",
                    Chipset      = "X370",
                    Socket       = "AM4",
                    Ram_type     = "DDR4",
                    Price        = "645"
                },
                new MOBO
                {
                    Name         = "Gigabyte GA-AB350-GAMING 3",
                    Manufacturer = "Gigabyte",
                    Standard     = "ATX",
                    Chipset      = "B350",
                    Socket       = "AM4",
                    Ram_type     = "DDR4",
                    Price        = "429"
                },
                new MOBO
                {
                    Name         = "ASRock Z370 EXTREME4",
                    Manufacturer = "ASRock",
                    Standard     = "ATX",
                    Chipset      = "Z370",
                    Socket       = "1151",
                    Ram_type     = "DDR4",
                    Price        = "655"
                }
            };

            foreach (MOBO m in Moboes)
            {
                context.MOBOes.Add(m);
            }
            context.SaveChanges();


            // CASE

            var Cases = new Case[]
            {
                new Case
                {
                    Name         = "Pure Base 600 ",
                    Manufacturer = "be quiet!",
                    Price        = "359"
                },
                new Case
                {
                    Name         = "Z3 PLUS",
                    Manufacturer = "Zalman",
                    Price        = "160"
                },
                new Case
                {
                    Name         = "Carbide 400C ",
                    Manufacturer = "Corsair",
                    Price        = "323"
                },
                new Case
                {
                    Name         = "Gladius M35",
                    Manufacturer = "SilentiumPC",
                    Price        = "188"
                },
                new Case
                {
                    Name         = "Define R5",
                    Manufacturer = "Fractal Design",
                    Price        = "469"
                }
            };

            foreach (Case c in Cases)
            {
                context.Cases.Add(c);
            }
            context.SaveChanges();

            // PSU

            var PSUs = new PSU[]
            {
                new PSU
                {
                    Name         = "EVGA Supernnova G2",
                    Manufacturer = "EVGA",
                    Wattage      = "550",
                    Price        = "329"
                },
                new PSU
                {
                    Name         = "Corsair VS",
                    Manufacturer = "Corsair",
                    Wattage      = "550",
                    Price        = "183"
                },
                new PSU
                {
                    Name         = "be quiet! Pure Power L8",
                    Manufacturer = "be quiet!",
                    Wattage      = "600",
                    Price        = "343"
                },
                new PSU
                {
                    Name         = "be quiet! POWER ZONE 650W",
                    Manufacturer = "be quiet!",
                    Wattage      = "650",
                    Price        = "406"
                },
                new PSU
                {
                    Name         = "Corsair RM550X",
                    Manufacturer = "Corsair",
                    Wattage      = "550",
                    Price        = "379"
                }
            };

            foreach (PSU c in PSUs)
            {
                context.PSUs.Add(c);
            }
            context.SaveChanges();


            // RAM

            var RAMs = new RAM[]
            {
                new RAM
                {
                    Name         = "Corsair Vengeance LPX",
                    Manufacturer = "Corsair",
                    Ram_type     = "DDR4",
                    Speed        = "3000",
                    Price        = "619"
                },
                new RAM
                {
                    Name         = "G.Skill Ripjaws V",
                    Manufacturer = "G.Skill",
                    Ram_type     = "DDR4",
                    Speed        = "3200",
                    Price        = "849"
                },
                new RAM
                {
                    Name         = "ADATA XPG",
                    Manufacturer = "ADATA",
                    Ram_type     = "DDR4",
                    Speed        = "2400",
                    Price        = "729"
                },
                new RAM
                {
                    Name         = "Ballistix Sport LT",
                    Manufacturer = "Ballistix",
                    Ram_type     = "DDR4",
                    Speed        = "2400",
                    Price        = "384"
                }
            };

            foreach (RAM c in RAMs)
            {
                context.RAMs.Add(c);
            }
            context.SaveChanges();

            // Cooler

            var Coolers = new Cooler[]
            {
                new Cooler
                {
                    Name   = "Noctua NH-D15",
                    Socket = "1151",
                    Fans   = "2",
                    Price  = "400"
                },
                new Cooler
                {
                    Name   = "SilentiumPC Grandis2 XE1436",
                    Socket = "AM4",
                    Fans   = "2",
                    Price  = "199"
                },
                new Cooler
                {
                    Name   = "be quiet! Dark Rock PRO 3 ",
                    Socket = "1151",
                    Fans   = "2",
                    Price  = "321"
                },
                new Cooler
                {
                    Name   = "Thermalright Macho Rev. B",
                    Socket = "AM4",
                    Fans   = "1",
                    Price  = "230"
                }
            };

            foreach (Cooler c in Coolers)
            {
                context.Coolers.Add(c);
            }
            context.SaveChanges();


            // GPU

            var GPUs = new GPU[]
            {
                new GPU
                {
                    Name         = "MSI GTX 1070TI GAMING",
                    Manufacturer = "MSI",
                    Chipset      = "GTX 1070TI",
                    TDP          = "200",
                    Price        = "2100"
                },
                new GPU
                {
                    Name         = "Gigabyte GeForce GTX1080 WINDFORCE OC",
                    Manufacturer = "Gigabyte",
                    Chipset      = "GTX 1080",
                    TDP          = "250",
                    Price        = "3199"
                },
                new GPU
                {
                    Name         = "Gigabyte GeForce GTX 1050Ti GAMING G1",
                    Manufacturer = "Gigabyte",
                    Chipset      = "GTX 1050TI",
                    TDP          = "120",
                    Price        = "889"
                },
                new GPU
                {
                    Name         = "ASUS GeForce GTX 1060 Strix OC 6GB",
                    Manufacturer = "MSI",
                    Chipset      = "GTX 1060",
                    TDP          = "150",
                    Price        = "1709"
                }
            };

            foreach (GPU c in GPUs)
            {
                context.GPUs.Add(c);
            }
            context.SaveChanges();


            // STORAGE
            var Storages = new Storage[]
            {
                new Storage
                {
                    Name         = "GOODRAM SSD IRIDIUM PRO",
                    Manufacturer = "GOODRAM",
                    Size         = "240",
                    Type         = "SSD",
                    Price        = "389"
                },
                new Storage
                {
                    Name         = "Crucial MX300",
                    Manufacturer = "Crucial",
                    Size         = "275",
                    Type         = "SSD",
                    Price        = "369"
                },
                new Storage
                {
                    Name         = "Transcend SSD370",
                    Manufacturer = "Transcend",
                    Size         = "128",
                    Type         = "SSD",
                    Price        = "259"
                },
                new Storage
                {
                    Name         = "Toshiba P300",
                    Manufacturer = "Toshiba",
                    Size         = "1000",
                    Type         = "HDD",
                    Price        = "189"
                },
                new Storage
                {
                    Name         = "Seagate BarraCuda",
                    Manufacturer = "Seagate",
                    Size         = "1000",
                    Type         = "HDD",
                    Price        = "189"
                }
            };

            foreach (Storage c in Storages)
            {
                context.Storages.Add(c);
            }
            context.SaveChanges();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Computer constructor requiring all parts
 /// </summary>
 /// <param name="serialNumber">The serial number of the Computer</param>
 /// <param name="name">The name of the Computer</param>
 /// <param name="pcCase">The pc case of the Computer</param>
 /// <param name="cpu">The cpu of the Computer</param>
 /// <param name="fan">The fan of the Computer</param>
 /// <param name="gCard">The Graphics Card of the Computer</param>
 /// <param name="memory">The Memory of the Computer</param>
 /// <param name="mBoard">The Motherboard of the Computer</param>
 /// <param name="power">The power supply of the Computer</param>
 /// <param name="storage">The storage of the computer</param>
 public Computer(int serialNumber, string name, Case pcCase, CPU cpu, Fan fan, GraphicsCard gCard, Memory memory, MOBO mBoard, PowerSupply power, Storage storage)
 {
     this.pcCase       = pcCase;
     this.cpu          = cpu;
     this.fan          = fan;
     this.gCard        = gCard;
     this.memory       = memory;
     this.mBoard       = mBoard;
     this.power        = power;
     this.storage      = storage;
     this.serialNumber = serialNumber;
     this.name         = name;
     price             = CalcPrice();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Secondary Constructor for database incrementation
 /// </summary>
 /// <param name="name">The Name of the Computer</param>
 /// <param name="pcCase">The pc case of the Computer</param>
 /// <param name="cpu">The CPU of the Computer</param>
 /// <param name="fan">The Fan of the Computer</param>
 /// <param name="gCard">The Graphics Card of the Computer</param>
 /// <param name="memory">The Memory of the Computer</param>
 /// <param name="mBoard">The Motherboard of the Computer</param>
 /// <param name="power">The Power Supply of the Computer</param>
 /// <param name="storage">The Storage of the Computer</param>
 public Computer(string name, Case pcCase, CPU cpu, Fan fan, GraphicsCard gCard, Memory memory, MOBO mBoard, PowerSupply power, Storage storage) : this(-1, name, pcCase, cpu, fan, gCard, memory, mBoard, power, storage)
 {
 }
Exemplo n.º 9
0
        public Test()
        {
            DbContextOptions <ApplicationDbContext> options;
            var builder = new DbContextOptionsBuilder <ApplicationDbContext>();

            builder.UseInMemoryDatabase();
            options = builder.Options;

            ApplicationDbContext _context = new ApplicationDbContext(options);

            _context.Database.EnsureDeleted();
            _context.Database.EnsureCreated();
            _context.SaveChanges();

            _service = new TestService(_context);

            var user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**"
            };
            var cpu = new CPU
            {
                Name         = "i5-8400",
                Manufacturer = "Intel",
                Series       = "i5",
                Socket       = "1151",
                Cores        = "6",
                TDP          = "65",
                iGPU         = 1,
                Price        = "829"
            };

            var mobo = new MOBO
            {
                Name         = "Z370-A PRO",
                Manufacturer = "MSI",
                Standard     = "ATX",
                Chipset      = "Z370",
                Socket       = "1151",
                Ram_type     = "DDR4",
                Price        = "519"
            };

            var casePC =
                new Case
            {
                Name         = "BIG",
                Manufacturer = "Corsair",
                Price        = "500"
            };


            var psu = new PSU
            {
                Name         = "EVGA Supernnova G2",
                Manufacturer = "EVGA",
                Wattage      = "550",
                Price        = "329"
            };

            var ram = new RAM
            {
                Name         = "Corsair Vengeance LPX",
                Manufacturer = "Corsair",
                Ram_type     = "DDR4",
                Speed        = "3000",
                Price        = "619"
            };

            var cooler = new Cooler
            {
                Name   = "Noctua NH-D15",
                Socket = "1151",
                Fans   = "2",
                Price  = "400"
            };

            var gpu = new GPU
            {
                Name         = "MSI GTX 1070TI GAMING",
                Manufacturer = "MSI",
                Chipset      = "GTX 1070TI",
                TDP          = "200",
                Price        = "2100"
            };

            _service.AddConfiguration(cpu, gpu, mobo, ram, psu, casePC, cooler, user);

            list   = _service.GetPCs();
            pcdata = list.FirstOrDefault();
        }