public void DeletePSU() { // Remove item from database if it already exists if (DC.ItemExists("Corsair CX550M")) { int tempID = DC.GetItems().Find(a => a.Name == "Corsair CX550M").ID; DC.DeleteItem(tempID, false); } // Test CPU Item item = new Item { Name = "Corsair CX550M", Price = 93.16m, Quantity = 2, Component = Database.Model.Type.PSU }; PSU psu = new PSU { Series = "SuperNOVA G3", Form = "ATX", Efficiency = "80+ Gold", Watts = 750, Modular = "Full" }; // Add Item Assert.IsTrue(DC.AddItem(item, psu), "Couldnt Add Item for test."); // Delete Item (Returns false if transaction couldnt be added) int id = DC.GetItems().Find(a => a.Name == item.Name).ID; Assert.IsTrue(DC.DeleteItem(id), "Failed to delete from database"); }
/// <summary> /// Deletes selected power supply. /// </summary> /// <param name="obj"></param> private async void ExecDeletePSUAsync(object obj) { PSU psu = (PSU)ProductListView.ProductListUserControl.PSUList.SelectedItem; PSUs.Remove(psu); switch (App.DataSource) { case ConnectionResource.LOCALAPI: await new WebServiceManager <PSU>().DeleteAsync(psu); break; case ConnectionResource.LOCALMYSQL: using (var ctx = new MysqlDbContext(ConnectionResource.LOCALMYSQL)) { ctx.DbSetPSUs.Attach(psu); ctx.DbSetPSUs.Remove(psu); await ctx.SaveChangesAsync(); } break; default: break; } }
public bool AddItem(Item _item, PSU _psu) { try { // Using database context using (var db = new InventorySystemContext()) { // Add CPU to database if item does not fail. if (AddItem(_item)) { // Get item ID var item = db.Items.First(c => c.Name == _item.Name); // Add Item to RAM PSU psu = _psu; psu.Item = item; db.PSUs.Add(_psu); db.SaveChanges(); } else { // Returns false if name exists. return(false); } } } catch (Exception e) { // Return false if failed. return(false); } // Return true if successful. return(true); }
// Use this for initialization void Start() { Hardware = GameObject.Find("Hardware"); cpu = Hardware.GetComponent <CPU>(); ram = Hardware.GetComponent <RAM>(); psu = Hardware.GetComponent <PSU>(); com = GetComponent <Computer>(); sc = GetComponent <SoundControl>(); appman = GetComponent <AppMan>(); CloseButton = new Rect(441, 1, 21, 21); MiniButton = new Rect(419, 1, 21, 21); SettingsButton = new Rect(397, 1, 21, 21); PosCheck(); ContextwindowRect.width = 100; if (CompactMode == true) { minimize = true; Minimize(); showSpecs = true; } }
public ActionResult Index() { //XmlEncrypt(); /*Creamos instancia del cliente webservice para poder inicializar sus Operaciones o metodos. verifica el web.config validando el Endpoint, en el Tag system.serviceModel*/ QuotationCarGenericPortTypeClient client = new QuotationCarGenericPortTypeClient(); var interceptorDePeticion = new CustomInspectorBehavior(); //client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "cf0b691745fd90204f387214e49ffc3e7b48f3c0"); //client.ClientCredentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "3febb2423e8baf23ae4ee30672551e766f0a536b"); client.Endpoint.EndpointBehaviors.Add(interceptorDePeticion); //instancia del request quotationCarGenericRequest request = RequestLiberty(); //Son las variables de salida que necesita el método #quotationCarGeneric. ElementoCodificado elementoCodificado = new ElementoCodificado(); Prima datosEconomicos = new Prima(); PSU[] PSU = new PSU[0]; var response = client.quotationCarGeneric(ref request.amparo, request.automovil, request.conductor, ref request.datosGestion, request.infoRequest, request.preguntaPoliza, request.preguntaRiesgo, request.preguntaTablaRiesgo, request.preguntaTablaPoliza, request.tomadorPersonaJuridica, request.tomadorPersonaNatural, request.usuario, out elementoCodificado, out datosEconomicos, out PSU); //XmlSerializer xmlSerializer = new XmlSerializer(typeof(QuotationCarGenericRq)); //using (StringWriter textwriter = new StringWriter()) //{ // xmlSerializer.Serialize(textwriter, new QuotationCarGenericRq()); // var lmao= textwriter.ToString(); //} return View(); }
public static void SavePSUToDB(string partid) { JObject chosenpart = GetPartData(partid); Entities ORM = new Entities(); PSU tempObj = new PSU(chosenpart["title"].ToString()); List <PSU> z = new List <PSU>(); z = ORM.PSUs.Where(x => x.ProductID == partid).ToList(); if (z.Count < 1) { tempObj.ProductID = chosenpart["product_id"].ToString(); tempObj.Description = "x"; tempObj.Brand = chosenpart["brand"].ToString(); tempObj.Price = int.Parse(chosenpart["price"].ToString()); tempObj.Stars = float.Parse(chosenpart["stars"].ToString()); tempObj.ImageLink = chosenpart["main_image"].ToString(); tempObj.Manufacturer = "x"; tempObj.Width = null; tempObj.Wattage = null; tempObj.Length = null; tempObj.Height = null; tempObj.FormFactor = GetFormFactor(ParseToArray(chosenpart["feature_bullets"])); ORM.PSUs.Add(tempObj); ORM.SaveChanges(); } }
public static void SavePSUsToDB() { List <JObject> searchedparts = new List <JObject>(); searchedparts = GetPartData(GetParts("PSU")); Entities ORM = new Entities(); foreach (JObject part in searchedparts) { string y = part["product_id"].ToString(); PSU tempPSU = new PSU(part["title"].ToString()); List <PSU> z = new List <PSU>(); z = ORM.PSUs.Where(x => x.ProductID == y).ToList(); if (z.Count < 1) { tempPSU.ProductID = part["product_id"].ToString(); tempPSU.Description = "x";//part["product_description"].ToString(); tempPSU.Brand = part["brand"].ToString(); tempPSU.Price = int.Parse(part["price"].ToString()); tempPSU.Stars = float.Parse(part["stars"].ToString()); tempPSU.ImageLink = part["main_image"].ToString(); tempPSU.Manufacturer = "x"; tempPSU.Width = null; tempPSU.Wattage = null; tempPSU.Length = null; tempPSU.Height = null; tempPSU.FormFactor = GetFormFactor(ParseToArray(part["feature_bullets"])); ORM.PSUs.Add(tempPSU); ORM.SaveChanges(); } } }
public void AddPSU() { // Remove item from database if it already exists if (DC.ItemExists("EVGA SuperNOVA 750")) { int id = DC.GetItems().Find(a => a.Name == "EVGA SuperNOVA 750").ID; DC.DeleteItem(id, false); } // Test CPU Item item = new Item { Name = "EVGA SuperNOVA 750", Price = 93.16m, Quantity = 2, Component = Database.Model.Type.PSU }; PSU psu = new PSU { Series = "SuperNOVA G3", Form = "ATX", Efficiency = "80+ Gold", Watts = 750, Modular = "Full" }; Assert.IsTrue(DC.AddItem(item, psu), "Failed to add test PSU."); Assert.IsTrue(DC.ItemExists("EVGA SuperNOVA 750")); }
private void CollectionChanged(NotifyCollectionChangedEventArgs e) { //Add if (e.Action == NotifyCollectionChangedAction.Add) { if (e.NewItems != null) { foreach (object item in e.NewItems) { if (item.GetType() == typeof(User)) { User user = (User)item; OnUserAdded?.Invoke(user, new EventArgs()); } } } } //Remove if (e.Action == NotifyCollectionChangedAction.Remove) { if (e.OldItems != null) { foreach (object item in e.OldItems) { if (item.GetType() == typeof(User)) { User user = (User)item; OnUserRemoved?.Invoke(user, new EventArgs()); } } } } //Updates if (e.Action == NotifyCollectionChangedAction.Replace) { if (e.NewItems != null) { foreach (Object item in e.NewItems) { if (item.GetType() == typeof(Output)) { Output output = (Output)item; OnOutputUpdated?.Invoke(this, new EventArgs()); } if (item.GetType() == typeof(User)) { User user = (User)item; OnUserUpdated?.Invoke(user, new EventArgs()); } if (item.GetType() == typeof(PSU)) { PSU psu = (PSU)item; OnPSUUpdated?.Invoke(psu, new EventArgs()); } } } } }
public DistinctProductList <PSU> GetPsuData() { MySqlCommand command = new MySqlCommand("SELECT Product.ProductID, Product.name, PSU.power, PSU.formFactor, PSU.modular, " + "PSU.width, PSU.depth, PSU.height, PSU.weight, PSU.brand " + "FROM Product, PSU " + "WHERE Product.ProductID = PSU.ProductID", connection); DistinctProductList <PSU> result = new DistinctProductList <PSU>(); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { object[] tempResult = new object[reader.FieldCount]; reader.GetValues(tempResult); PSU row = new PSU("PSU", (int)tempResult[0], (string)tempResult[1], (string)tempResult[2], (string)tempResult[3], reader.GetBoolean(4), (string)tempResult[5], (string)tempResult[6], (string)tempResult[7], (string)tempResult[8], (string)tempResult[9]); result.Add(row); } reader.Close(); return(result); }
public bool GetPSUs() { bool result = false; APIResponse apiresponse = _connect.Get("/psus", Connect.Method.GET); if (apiresponse.StatusCode == 200) { API_PSUs apipsus = JSON.Deserialize <API_PSUs>(apiresponse.Response); if (apipsus != null) { List <PSU> tmppsus = new List <PSU>(); foreach (API_PSUs.Data data in apipsus.data) { PSU tmp = new PSU(); tmp.Id = data.id; tmp.Number = data.attributes.psuNumber; tmp.Status = data.attributes.status; tmp.InternalTemperature = data.attributes.internalTemperature; tmp.AmbientTemperature = data.attributes.ambientTemperature; tmp.FanSpeed = data.attributes.fanSpeed; tmp.MainsCurrent = data.attributes.mainsCurrent; tmp.OutputCurrent = data.attributes.outputCurrent; tmppsus.Add(tmp); } foreach (PSU psu in tmppsus) { if (!PSUs.Contains(psu)) { int index = -1; for (int i = 0; i < PSUs.Count; i++) { if (PSUs[i].Id == psu.Id) { index = i; } } if (index > -1) { PSUs[index] = psu; } else { PSUs.Add(psu); } } } result = true; } } return(result); }
public Computer(CPU cpu, Gpu gpu, RAM ram, Motherboard motherboard, PSU psu, PcCase case1) { Cpu = cpu; Gpu = gpu; Ram = ram; Motherboard = motherboard; Psu = psu; Case1 = case1; }
//Adds the secelcted psu the the reciept private void btnPSU_Click(object sender, EventArgs e) { //Sets the variables that will be used in the method int selected = 0; string name = ""; double price = 0; //Clears the psu object psu.Clear(); //Each item in the chekbox is checked to see if it is checked, if it is then it will be dispayed in the case recipt box for (int i = 0; i < cbxPSU.Items.Count; i++) { //Statement that checks is the checked item is i if (cbxPSU.GetItemChecked(i)) { selected = i; } } //Checks the index of the seleced PSU if (selected == 0) { name = "PSU A"; price = 40.00; } else if (selected == 1) { name = "PSU B"; price = 39.00; } else if (selected == 2) { name = "PSU C"; price = 25.00; } else if (selected == 3) { name = "PSU D"; price = 50.00; } //displays the name and total in the psu reciept list box lstPSUReciept.Items.Add(name + " | £" + price.ToString()); //Stores psu PSU p = new PSU { name = name, price = price }; //Adds the value of p to the psu list psu.Add(p); }
public bool IsPowerEnough(PSU psu, CPU cpu, List <Gpu> gpus) { double psuPower = psu.PowerEfficiency; int powerconsumption = GetPower(cpu, gpus); if (psuPower > powerconsumption) { return(true); } return(false); }
public CreateViewModel() { Item = new Item(); CPU = new CPU(); CPUCooler = new CPUCooler(); GPU = new GPU(); Motherboard = new Motherboard(); PSU = new PSU(); RAM = new RAM(); Case = new Case(); }
public Desktop(Cooler cooler, DesktopCPU cpu, Disk drive, DesktopGPU gpu, DesktopMotherboard motherboard, PSU psu, RAM ram) { try { if (cooler == null) { throw new ArgumentNullException("cooler"); } if (cpu == null) { throw new ArgumentNullException("cpu"); } if (drive == null) { throw new ArgumentNullException("drive"); } if (gpu == null) { throw new ArgumentNullException("gpu"); } if (motherboard == null) { throw new ArgumentNullException("motherboard"); } if (psu == null) { throw new ArgumentNullException("psu"); } if (ram == null) { throw new ArgumentNullException("ram"); } Cooler = cooler; _cpu = cpu; _disk = drive; _gpu = gpu; _motherboard = motherboard; _psu = psu; _ram = ram; } catch (ArgumentNullException exception) { throw exception; } catch (ArgumentException exception) { throw exception; } catch (Exception exception) { throw exception; } }
public PsuDto GetPsuById(string id) { PsuDto psuDto = new PsuDto(); PSU psu = this.context.psus.FirstOrDefault(x => x.model == id); psuDto.model = psu.model; psuDto.powerEfficiency = psu.powerEfficiency; psuDto.price = psu.price; return(psuDto); }
public ActionResult PSU(PSU psu) { newItem.PSU = psu; // save to database DatabaseController db = new DatabaseController(); db.AddItem(newItem.Item, newItem.PSU); newItem = null; return(RedirectToAction("Index", "Inventory")); }
public PSU GetPsuFromModel(string psuModel) { PSU resultPsu = new PSU(); foreach (var psu in context.psus) { if (psuModel == psu.model) { resultPsu = psu; } } return(resultPsu); }
public DesktopPC(Case pcCase, Cooler cooler, CPU cpu, GPU gpu, HDD hdd, Keyboard keyboard, Monitor monitor, MotherBoard motherBoard, Mouse mouse, PSU psu, RAM ram) { Case = pcCase; Cooler = cooler; CPU = cpu; GPU = gpu; HDD = hdd; Keyboard = keyboard; Monitor = monitor; MotherBoard = motherBoard; Mouse = mouse; PSU = psu; RAM = ram; }
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(); }
private static async Task SeedPsus(ApplicationDbContext dbContext) { using (SqlConnection connection = new SqlConnection(Config.ConnectionString)) { connection.Open(); var command = new SqlCommand(SqlCommands.SelectPSUsSql, connection); var psus = new List <PSU>(); SqlDataReader reader = await command.ExecuteReaderAsync(); try { while (reader.Read()) { var psu = new PSU { Brand = reader["Brand"].ToString(), EnergyEfficiency = reader["EnergyEfficiency"].ToString(), Image = (byte[])reader["Image"], ImgUrl = reader["ImgUrl"].ToString(), Fans = reader["Fans"].ToString(), MaximumPower = reader["MaximumPower"].ToString(), Name = reader["Name"].ToString(), Modular = reader["Modular"].ToString(), Type = reader["Type"].ToString(), CategoryId = 7, }; psus.Add(psu); } dbContext.PowerSupplies.AddRange(psus); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } finally { reader.Close(); } } }
public override string ToString() { var itemToString = string.Empty; StringBuilder sb = new StringBuilder(); sb.Append("Desktop PC Specs:"); sb.Append(string.Format("\t {0}", Case.ToString())); sb.Append(string.Format("\t {0}", Cooler.ToString())); sb.Append(string.Format("\t {0}", CPU.ToString())); sb.Append(string.Format("\t {0}", GPU.ToString())); sb.Append(string.Format("\t {0}", HDD.ToString())); sb.Append(string.Format("\t {0}", Keyboard.ToString())); sb.Append(string.Format("\t {0}", Monitor.ToString())); sb.Append(string.Format("\t {0}", MotherBoard.ToString())); sb.Append(string.Format("\t {0}", Mouse.ToString())); sb.Append(string.Format("\t {0}", PSU.ToString())); sb.Append(string.Format("\t {0}", RAM.ToString())); itemToString = sb.ToString(); return(itemToString); }
public async Task <IEnumerable <PSU> > GatherPowerSuppliesData() { var videoCards = new List <PSU>(); var productUrls = new List <string>(); var parser = new HtmlParser(); var client = new HttpClient(); for (int page = 1; page <= 100; page++) { Console.Write($"{page} => "); var url = $"https://www.newegg.com/Desktop-Memory/SubCategory/ID-58/Page-{page}"; string htmlContent = null; for (var i = 0; i < 10; i++) { try { var response = await client.GetAsync(url); htmlContent = await response.Content.ReadAsStringAsync(); break; } catch { Console.Write('!'); Thread.Sleep(500); } } if (string.IsNullOrWhiteSpace(htmlContent)) { break; } var document = await parser.ParseDocumentAsync(htmlContent); var elements = document.GetElementsByClassName("item-container "); if (elements.Length == 0) { break; } foreach (var element in elements) { string pcPartPickerUrl = null; var options = element.InnerHtml.Split('\n', StringSplitOptions.RemoveEmptyEntries); foreach (var option in options) { if (option.Contains("href=") && option.Contains("item-img")) { var productUrlUntrimmed = option.Substring(option.IndexOf('/')); var productUrl = productUrlUntrimmed.Substring(0, productUrlUntrimmed.Length - 19); pcPartPickerUrl = "https:" + productUrl; productUrls.Add(pcPartPickerUrl); } } } } int count = 0; foreach (var url in productUrls) { string htmlContent = null; for (var i = 0; i < 10; i++) { try { var response = await client.GetAsync(url); htmlContent = await response.Content.ReadAsStringAsync(); break; } catch { Console.Write('!'); Thread.Sleep(500); } } Console.WriteLine(count); count++; var document = await parser.ParseDocumentAsync(htmlContent); var manufacturerInfo = document.GetElementById("MfrContact"); string productUrl = string.Empty; if (manufacturerInfo != null) { productUrl = manufacturerInfo.GetElementsByTagName("a")[0].InnerHtml; } var productSpecs = document.GetElementById("detailSpecContent"); string productSpecsInnerHtml = string.Empty; if (productSpecs == null) { continue; } productSpecsInnerHtml = productSpecs.InnerHtml; var specs = productSpecsInnerHtml.Split("<dl>", StringSplitOptions.RemoveEmptyEntries); var productName = string.Empty; if (specs[0].Contains("<span>")) { productName = specs[0].Substring(specs[0].IndexOf("<span>") + 6).Trim(); productName = productName.Substring(0, productName.IndexOf("</span>")).Trim(); } var videoCard = new PSU { Name = productName, ProductUrl = productUrl, }; var imgHtmlElemnts = document.GetElementsByName("gallery"); string imgHtml = string.Empty; if (imgHtmlElemnts.Length > 0) { imgHtml = imgHtmlElemnts[0].InnerHtml; imgHtml = imgHtml.Substring(imgHtml.IndexOf("//") + 2); imgHtml = imgHtml.Substring(0, imgHtml.IndexOf(">") - 1); } if (imgHtml.Length > 0) { videoCard.ImgUrl = imgHtml; } foreach (var spec in specs) { if (spec.Contains("<dt>") && spec.Contains("<dd>")) { var replaced = spec.Replace("<dt>", "|"); replaced = replaced.Replace("</dt>", "|"); replaced = replaced.Replace("<dd>", "|"); replaced = replaced.Replace("</dd>", "|"); var specsList = replaced.Split('|', StringSplitOptions.RemoveEmptyEntries); var specName = specsList[0]; var specValue = specsList[1]; if (specName.Contains("a data")) { specName = specName.Substring(specName.IndexOf(">") + 1); specName = specName.Substring(0, specName.IndexOf("<")); } switch (specName) { case "Brand": videoCard.Brand = specValue; break; case "Type": videoCard.Type = specValue; break; case "Maximum Power": videoCard.MaximumPower = specValue; break; case "Fans": videoCard.Fans = specValue; break; case "Modular": videoCard.Modular = specValue; break; case "Energy-Efficient": videoCard.EnergyEfficiency = specValue; break; default: break; } } } videoCards.Add(videoCard); } return(videoCards); }
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(); }
/// <summary> /// Adds the selected product to the cart's items. /// </summary> /// <param name="obj"></param> private void ExecAddToCart(object obj) { ProductListUserControl productListUC = CartView.CartUC.ProductsUC; CartItem cartItem = new CartItem(); cartItem.Cart = Cart; cartItem.Quantity = 1; if (productListUC.CPUList.SelectedIndex != -1) // CPU { CPU cpu = (CPU)productListUC.CPUList.SelectedItem; CPUs.Remove(cpu); cartItem.Product = cpu; cartItem.Price = cpu.Price; } else if (productListUC.GPUList.SelectedIndex != -1) // GPU { GPU gpu = (GPU)productListUC.GPUList.SelectedItem; GPUs.Remove(gpu); cartItem.Product = gpu; cartItem.Price = gpu.Price; } else if (productListUC.MotherboardList.SelectedIndex != -1) // Motherboard { Motherboard motherboard = (Motherboard)productListUC.MotherboardList.SelectedItem; Motherboards.Remove(motherboard); cartItem.Product = motherboard; cartItem.Price = motherboard.Price; } else if (productListUC.MemoryList.SelectedIndex != -1) // Memory { Memory memory = (Memory)productListUC.MemoryList.SelectedItem; Rams.Remove(memory); cartItem.Product = memory; cartItem.Price = memory.Price; } else if (productListUC.StorageList.SelectedIndex != -1) // Storage { Storage storage = (Storage)productListUC.StorageList.SelectedItem; StorageComponents.Remove(storage); cartItem.Product = storage; cartItem.Price = storage.Price; } else if (productListUC.PSUList.SelectedIndex != -1) // PSU { PSU psu = (PSU)productListUC.PSUList.SelectedItem; PSUs.Remove(psu); cartItem.Product = psu; cartItem.Price = psu.Price; } else // Case { Case pcCase = (Case)productListUC.CaseList.SelectedItem; Cases.Remove(pcCase); cartItem.Product = pcCase; cartItem.Price = pcCase.Price; } cartItem.Product.Stock--; Cart.Total += cartItem.Price; Cart.Items.Add(cartItem); }
public static Desktop CreateDesktop(Cooler cooler, DesktopCPU cpu, Disk disk, DesktopGPU gpu, DesktopMotherboard motherboard, PSU psu, RAM ram) { return(new Desktop(cooler, cpu, disk, gpu, motherboard, psu, ram)); }
// Load Items from CSV file or text using TextFieldParser private static void Load(string source, List <Part> list, StringReader sr = null) { dynamic tfpSource; if (sr != null) { tfpSource = sr; } else { tfpSource = source; } using (TextFieldParser tfp = new TextFieldParser(tfpSource)) { tfp.TextFieldType = FieldType.Delimited; tfp.SetDelimiters(","); list.Clear(); while (!tfp.EndOfData) { var currentItem = tfp.ReadFields(); Part currentItemObject = null; // Transform current CSV line to Part switch (currentItem[0]) { case "CPU": currentItemObject = new CPU( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], double.Parse(currentItem[7]), currentItem[8], int.Parse(currentItem[9]), currentItem[10], currentItem[11], int.Parse(currentItem[12])); list.Add(currentItemObject); break; case "MotherBoard": currentItemObject = new MotherBoard( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], currentItem[7], currentItem[8], currentItem[9], currentItem[10]); list.Add(currentItemObject); break; case "RAM": currentItemObject = new RAM( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], int.Parse(currentItem[7]), currentItem[8], int.Parse(currentItem[9])); list.Add(currentItemObject); break; case "VideoCard": currentItemObject = new VideoCard( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], currentItem[7], currentItem[8], currentItem[9], int.Parse(currentItem[10])); list.Add(currentItemObject); break; case "PSU": currentItemObject = new PSU( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], int.Parse(currentItem[7]), Dimensions.Parse(currentItem[8]), currentItem[9], int.Parse(currentItem[10]), int.Parse(currentItem[11])); list.Add(currentItemObject); break; case "SSD": currentItemObject = new SSD( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], int.Parse(currentItem[7]), currentItem[8], currentItem[9], double.Parse(currentItem[10]), bool.Parse(currentItem[11]), int.Parse(currentItem[12]), int.Parse(currentItem[13])); list.Add(currentItemObject); break; case "HDD": currentItemObject = new HDD( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], int.Parse(currentItem[7]), currentItem[8], int.Parse(currentItem[9]), double.Parse(currentItem[10]), int.Parse(currentItem[11]), int.Parse(currentItem[12]), bool.Parse(currentItem[13])); list.Add(currentItemObject); break; case "Case": currentItemObject = new Case( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], currentItem[7], Dimensions.Parse(currentItem[8]), int.Parse(currentItem[9]), int.Parse(currentItem[10]), int.Parse(currentItem[11]), bool.Parse(currentItem[12])); list.Add(currentItemObject); break; case "Monitor": currentItemObject = new Monitor( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], double.Parse(currentItem[7]), currentItem[8], currentItem[9], currentItem[10], bool.Parse(currentItem[11]), (IO)int.Parse(currentItem[12]), Dimensions.Parse(currentItem[13]), double.Parse(currentItem[14]), (Color)int.Parse(currentItem[15])); list.Add(currentItemObject); break; case "Mouse": currentItemObject = new Mouse( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], currentItem[7], int.Parse(currentItem[8]), int.Parse(currentItem[9]), double.Parse(currentItem[10]), currentItem[11], Dimensions.Parse(currentItem[12]), bool.Parse(currentItem[13]), (IO)int.Parse(currentItem[14]), (Color)int.Parse(currentItem[15])); list.Add(currentItemObject); break; case "Keyboard": currentItemObject = new Keyboard( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], currentItem[7], currentItem[8], currentItem[9], currentItem[10], int.Parse(currentItem[11]), Dimensions.Parse(currentItem[12]), bool.Parse(currentItem[13]), double.Parse(currentItem[14]), (IO)int.Parse(currentItem[15]), (Color)int.Parse(currentItem[16])); list.Add(currentItemObject); break; case "Speakers": currentItemObject = new Speakers( currentItem[1], currentItem[2], currentItem[3], decimal.Parse(currentItem[4]), currentItem[5], currentItem[6], double.Parse(currentItem[7]), double.Parse(currentItem[8]), currentItem[9], bool.Parse(currentItem[10]), (IO)int.Parse(currentItem[11]), Dimensions.Parse(currentItem[12]), double.Parse(currentItem[13]), (Color)int.Parse(currentItem[14])); list.Add(currentItemObject); break; default: throw new Exception($"Unknown part: \"{currentItem[0]}\""); } } } }
private void LoadData() { var nl = Environment.NewLine; var caseDict = new Dictionary <RecommendationType, Part> { { RecommendationType.Best, new Part { Name = "海盗船 400Q", Description = "更好地静音,冷却,防尘设计。尺寸较小:425mm(长)x 215mm(宽)x 464mm(高)。", Brand = "海盗船 Corsair", PartType = PartType.Case, Price = 699, Recommendation = RecommendationType.Best, Pid = "5272478", ImageUrl = "pack://application:,,,/Resources/case_best.jpg" } }, { RecommendationType.Ok, new Part { Name = "先马 黑洞3", Description = "静音机箱。530(长)*232(宽)*466(高)mm。", Brand = "先马", PartType = PartType.Case, Price = 399, Recommendation = RecommendationType.Ok, Pid = "2917029", ImageUrl = "pack://application:,,,/Resources/case_ok.jpg" } } }; Case.LoadParts(caseDict); Case.SetTitle("机箱", $"机箱主要考虑扩展性、防尘、机箱内通风设计、静音和外观。{nl}扩展性对于普通办公不重要。防尘和通风关系到硬件的寿命,静音和外观关系到工作环境。"); Case.ShowChoices(new[] { false, true, true }); var cpuDict = new Dictionary <RecommendationType, Part> { { RecommendationType.Best, new Part { Name = "i5 8600K", Description = "8代酷睿 6核6线程 3.6GHz。", Brand = "英特尔 Intel", PartType = PartType.CPU, Price = 1799, Recommendation = RecommendationType.Best, Pid = "5008425", ImageUrl = "pack://application:,,,/Resources/cpu_best.jpg" } }, { RecommendationType.Ok, new Part { Name = "i5 8500", Description = "8代酷睿 6核6线程 3.0GHz。", Brand = "英特尔 Intel", PartType = PartType.CPU, Price = 1399, Recommendation = RecommendationType.Ok, Pid = "6405178", ImageUrl = "pack://application:,,,/Resources/cpu_ok.jpg" } }, { RecommendationType.Basic, new Part { Name = "i5 8400", Description = "8代酷睿 6核6线程 2.8GHz", Brand = "英特尔 Intel", PartType = PartType.CPU, Price = 1349, Recommendation = RecommendationType.Basic, Pid = "5008397", ImageUrl = "pack://application:,,,/Resources/cpu_basic.jpg" } } }; CPU.LoadParts(cpuDict); CPU.SetTitle("中央处理器 CPU", $"CPU主要看核心数、频率(xxxGHz)。数字越大越好。{nl}我觉得我们没有必要买“最佳”(i5 8600K),普通办公i5 8500“够用”就好,i5 8400“基本”也能凑合。"); var mbDict = new Dictionary <RecommendationType, Part> { { RecommendationType.Ok, new Part { Name = "华擎 Z370 Pro4", Description = "一块够用且便宜的主板。", Brand = "华擎", PartType = PartType.Motherboard, Price = 759, Recommendation = RecommendationType.Ok, Pid = "5221329", ImageUrl = "pack://application:,,,/Resources/mb_ok.jpg" } } }; MotherBoard.LoadParts(mbDict); MotherBoard.SetTitle("主板", "主板的选择主要是考虑CPU的适配,电路保护功能,扩展功能和电脑配件的接口。我们不需要太复杂的功能,也不需要安装任何配件,选一块便宜够用的就好。"); MotherBoard.ShowChoices(new[] { false, true, false }); var gpuDict = new Dictionary <RecommendationType, Part> { { RecommendationType.Basic, new Part { Name = "无", PartType = PartType.Graphic_Card, Price = 0, Recommendation = RecommendationType.Basic, } } }; GPU.LoadParts(gpuDict, RecommendationType.Basic); GPU.SetTitle("显卡", $"除非是玩游戏,或者有工作需要(图像处理、复杂3D模型设计等),不需要显卡。"); GPU.ShowChoices(new[] { false, false, false }); var hdd1Dict = new Dictionary <RecommendationType, Part> { { RecommendationType.Best, new Part { Name = "三星 固态硬盘 960 EVO 500G M.2 NVMe", Description = "500G容量,读取速度 3200 MB/秒,写入速度 1800 MB/秒。", Brand = "三星 Samsung", PartType = PartType.Hard_Drive_1, Price = 1399, Recommendation = RecommendationType.Best, Pid = "4173878", ImageUrl = "pack://application:,,,/Resources/hdd1_best.jpg" } }, { RecommendationType.Ok, new Part { Name = "三星 固态硬盘 860 EVO 500G", Description = "500G容量,读取速度 550 MB/秒,写入速度 520 MB/秒。", Brand = "三星 Samsung", PartType = PartType.Hard_Drive_1, Price = 899, Recommendation = RecommendationType.Ok, Pid = "6212482", ImageUrl = "pack://application:,,,/Resources/hdd1_ok.jpg" } }, { RecommendationType.Basic, new Part { Name = "希捷 固态机械混合硬盘 1TB SATA3 ST1000DX002", Description = "1TB (1000GB)容量,读取写入速度 150MB/秒。", Brand = "希捷 SEAGATE", PartType = PartType.Hard_Drive_1, Price = 569, Recommendation = RecommendationType.Basic, Pid = "3052959", ImageUrl = "pack://application:,,,/Resources/hdd1_basic.jpg" } } }; HDD1.LoadParts(hdd1Dict); HDD1.SetTitle("硬盘 1", $"硬盘主要看容量和读写速度。500G-1T的容量一般来说够用了,除非要存大量的音乐和电影。{nl}读写速度对于电脑的性能提升很重要。现代电脑的卡顿多半是因为读写速度低造成的。"); var hdd2Dict = new Dictionary <RecommendationType, Part> { { RecommendationType.Basic, new Part { Name = "无", PartType = PartType.Hard_Drive_2, Price = 0, Recommendation = RecommendationType.Basic, } } }; HDD2.LoadParts(hdd2Dict, RecommendationType.Basic); HDD2.SetTitle("硬盘 2", $"如果以后第一块硬盘放满了,再买就是。"); HDD2.ShowChoices(new[] { false, false, false }); var ramDict = new Dictionary <RecommendationType, Part> { { RecommendationType.Best, new Part { Name = "金士顿 Fury系列 DDR4 2400 16G (8GBx2)", Description = "最便宜的双通道16G 2400内存条。", Brand = "金士顿 Kingston", PartType = PartType.Ram, Price = 1399, Recommendation = RecommendationType.Best, Pid = "2121093", ImageUrl = "pack://application:,,,/Resources/ram_best.jpg" } }, { RecommendationType.Ok, new Part { Name = "金士顿 Fury系列 DDR4 2400 8G (4GBx2)", Description = "最便宜的双通道8G 2400内存条。", Brand = "金士顿 Kingston", PartType = PartType.Ram, Price = 799, Recommendation = RecommendationType.Ok, Pid = "2551101", ImageUrl = "pack://application:,,,/Resources/ram_ok.jpg" } } }; Ram.LoadParts(ramDict); Ram.SetTitle("内存条", $"网页开太多了,卡?程序开太多了,卡?多半是内存不够引起的。16G的内存目前看来,在家用的情形下绝对够用了。8G的内存也基本够用,记得别开太多网页或程序就好。"); Ram.ShowChoices(new[] { false, true, true }); var psuDict = new Dictionary <RecommendationType, Part> { { RecommendationType.Best, new Part { Name = "酷冷至尊 额定550W V550", Description = "550W 功率,金牌认证,5年质保", Brand = "酷冷至尊", PartType = PartType.PSU, Price = 499, Recommendation = RecommendationType.Best, Pid = "1852502", ImageUrl = "pack://application:,,,/Resources/psu_best.jpg" } }, { RecommendationType.Ok, new Part { Name = "安钛克 VP500 额定500W", Description = "500W 功率,铜牌认证,3年质保", Brand = "安钛克", PartType = PartType.PSU, Price = 329, Recommendation = RecommendationType.Ok, Pid = "7408072", ImageUrl = "pack://application:,,,/Resources/psu_ok.jpg" } } }; PSU.LoadParts(psuDict); PSU.SetTitle("电源", $"电源主要考虑额定功率,认证级别和质保。我们不会用到很大的功率,所以500W足矣。认证级别有铜、金、铂金等。认证级别越高,电压越稳定,电流越纯净,对设备的损害也越小。普通用用的话,铜牌就够用了。"); PSU.ShowChoices(new[] { false, true, true }); var mouseDict = new Dictionary <RecommendationType, Part> { { RecommendationType.Best, new Part { Name = "罗技 MX Master 2S 无线蓝牙", Description = "无线或蓝牙连接,厚实,手感舒适。可同时连接并控制3台计算机,有9个扩展键。罗技暗区激光技术-业界最高精确度,可在任何桌面(包括玻璃)上使用。我在英国用的就是这个。", Brand = "罗技 Logitech", PartType = PartType.Mouse, Price = 599, Recommendation = RecommendationType.Best, Pid = "4294661", ImageUrl = "pack://application:,,,/Resources/mouse_best.jpg" } }, { RecommendationType.Ok, new Part { Name = "罗技 M720 无线蓝牙", Description = "无线或蓝牙连接。可同时连接并控制3台计算机,有8个扩展键。罗技高精度光电。", Brand = "罗技 Logitech", PartType = PartType.Mouse, Price = 299, Recommendation = RecommendationType.Ok, Pid = "15942194222", ImageUrl = "pack://application:,,,/Resources/mouse_ok.jpg" } }, { RecommendationType.Basic, new Part { Name = "罗技 M100r 光电鼠标", Description = "普通的消费类鼠标。", Brand = "罗技 Logitech", PartType = PartType.Mouse, Price = 45, Recommendation = RecommendationType.Basic, Pid = "692919", ImageUrl = "pack://application:,,,/Resources/mouse_basic.jpg" } } }; Mouse.LoadParts(mouseDict, RecommendationType.Best); Mouse.SetTitle("鼠标", $"鼠标是最重要的配件之一了。主要考虑舒适度和精确性。罗技的鼠标是我用过最舒适的鼠标了,所以我就没考虑其他品牌。鼠标的精确性越高,鼠标用起来越顺手,指针操作起来越不费力。罗技的暗区激光技术是目前最好的。{nl}强烈推荐罗技的MX Master 2S。"); var keyboardDict = new Dictionary <RecommendationType, Part> { { RecommendationType.Best, new Part { Name = "樱桃 MX-BOARD 2.0 G80-3800 白色 茶轴", Description = "机械键盘,茶轴,特色是安静,反馈适当,适合打字。", Brand = "樱桃 Cherry", PartType = PartType.Keyboard, Price = 459, Recommendation = RecommendationType.Best, Pid = "2300073", ImageUrl = "pack://application:,,,/Resources/keyboard_best.jpg" } }, { RecommendationType.Ok, new Part { Name = "罗技 K840 机械键盘", Description = "机械键盘,Romer G轴,特色是声音清脆,键程短(轻按一下就出字,没习惯前容易按错)。我用的是这个。", Brand = "罗技 Logitech", PartType = PartType.Keyboard, Price = 349, Recommendation = RecommendationType.Ok, Pid = "5025970", ImageUrl = "pack://application:,,,/Resources/keyboard_ok.jpg" } }, { RecommendationType.Basic, new Part { Name = "罗技 K120 薄膜键盘", Description = "薄膜键盘,没什么特别的。", Brand = "罗技 Logitech", PartType = PartType.Keyboard, Price = 45, Recommendation = RecommendationType.Basic, Pid = "262214", ImageUrl = "pack://application:,,,/Resources/keyboard_basic.jpg" } } }; Keyboard.LoadParts(keyboardDict, RecommendationType.Best); Keyboard.SetTitle("键盘", $"主要是打字的舒适度。笔记本电脑上的键盘都是薄膜键盘,按起来手感一般,没什么反馈,但是便宜。机械键盘是老科技,那些噼里啪啦响的老键盘都是机械键盘。薄膜键盘的出现一定程度上导致机械键盘濒临灭绝。但是最近大家开始还念机械键盘打字的手感,所以机械键盘又开始流行了。"); var monitorDict = new Dictionary <RecommendationType, Part> { { RecommendationType.Best, new Part { Name = "戴尔 U2518DR", Description = "25寸,高清2K分辨率屏(像素颗粒比较小),色彩精准,可调节视角、高度,屏幕可90度旋转。", Brand = "戴尔 Dell", PartType = PartType.Monitor, Price = 2199, Recommendation = RecommendationType.Best, Pid = "4396371", ImageUrl = "pack://application:,,,/Resources/monitor_best.jpg" } }, { RecommendationType.Ok, new Part { Name = "Dell U2417H", Description = "24寸,普通 1920 x 1080 分辨率屏,色彩精准,窄边框,可调节视角、高度,屏幕可90度旋转。", Brand = "戴尔 Dell", PartType = PartType.Monitor, Price = 1499, Recommendation = RecommendationType.Ok, Pid = "2316993", ImageUrl = "pack://application:,,,/Resources/monitor_ok.jpg" } }, { RecommendationType.Basic, new Part { Name = "松人", Description = "24寸,普通 1920 x 1080 分辨率屏,色彩一般。", Brand = "松人", PartType = PartType.Monitor, Price = 579, Recommendation = RecommendationType.Basic, Pid = "26654068529", ImageUrl = "pack://application:,,,/Resources/monitor_basic.jpg" } } }; Monitor.LoadParts(monitorDict); Monitor.SetTitle("显示器", $"显示器主要考虑接口数量、分辨率、色彩精准度、屏幕的可调节度和外观。这三款显示器的接口数量都没问题,差异主要在其他几项上:{nl}分辨率越高,字和图片越清晰。色彩精准度在编辑照片时很重要,对于看图看视频也有一定的影响。屏幕的调节度有2点可以考虑:1. 俯仰角,2. 屏幕旋转。俯仰角关系到观看的舒适度,屏幕旋转是指可以把屏幕旋转90度,横屏变为竖屏,对看文字、编辑文字有用。{nl}我个人不赞成购买太差的屏幕,因为用电脑时99%的时间都在看屏幕。"); Accessory1.LoadParts(new Dictionary <RecommendationType, Part> { { RecommendationType.Best, new Part { Name = "TP-Link TL-WDN8280 3200M双频无线PCI-E网卡", Description = "名称中的3200M是指传输速度是3200M/s。如果家里的网络没有那么快的话,买1900M甚至1300M的也够了。不过需注意的是,1300M和1900M的信号接受能力也有所下降。如果房间离路由器远的话,要注意一下。", Brand = "普联 TP-Link", PartType = PartType.Accessory, Price = 579, Recommendation = RecommendationType.Best, Pid = "26654068529", ImageUrl = "pack://application:,,,/Resources/wirelesscard.jpg" } }, { RecommendationType.Ok, new Part { Name = "TP-LINK TL-PA1000套装 1000M 千兆有线电力线", Description = "工作原理是把家里的电线当成网线传输网络数据。优点是速度比无线网络稳定,缺点是电力线布置不恰当的话,会影响信号稳定性。我建议,如果路由器离电脑远(15米开外还隔着墙)的话,买这个比较好。否则,无线网卡省心.", Brand = "普联 TP-Link", PartType = PartType.Accessory, Price = 579, Recommendation = RecommendationType.Ok, Pid = "6627771", ImageUrl = "pack://application:,,,/Resources/powerline.jpg" } }, { RecommendationType.Basic, new Part { Name = "无", PartType = PartType.Accessory, Price = 0, Recommendation = RecommendationType.Basic } } }, RecommendationType.Basic); Accessory1.SetTitle("网络", $"如果拉网线太麻烦的话,可以买一张无线网卡,也可以买有线电力线。"); }
public Dictionary <string, string> GetObject(int _id) { Dictionary <string, string> keyValuePairs = new Dictionary <string, string>(); using (var db = new InventorySystemContext()) { if (db.Items.Any(i => i.ID == _id)) { Item item = db.Items.First(i => i.ID == _id); // Check all lists and delete where necessary // Case switch (item.Component) { case (Model.Type.CASE): Case @case = db.Cases.First(c => c.ItemID == _id); keyValuePairs.Add("Type", @case.Type.ToString()); keyValuePairs.Add("External 5 1/4\" bays", @case.ExtFiveBays.ToString()); keyValuePairs.Add("Internal 3 1/3\" bays", @case.IntThreeBays.ToString()); break; case (Model.Type.CPU): CPU cpu = db.CPUs.First(c => c.ItemID == _id); keyValuePairs.Add("Power", cpu.Power.ToString() + " W"); keyValuePairs.Add("Speed", cpu.Speed.ToString() + " GHz"); break; case (Model.Type.CPUCOOLER): CPUCooler cpuCooler = db.CPUCoolers.First(c => c.ItemID == _id); keyValuePairs.Add("Fan RPM", cpuCooler.FanRPM); keyValuePairs.Add("Noise Level", cpuCooler.NoiseLevel.ToString() + " dB"); break; case (Model.Type.GPU): GPU gpu = db.GPUs.First(c => c.ItemID == _id); keyValuePairs.Add("Series", gpu.Series); keyValuePairs.Add("Chipset", gpu.Chipset); keyValuePairs.Add("Memory", gpu.Memory); keyValuePairs.Add("Core Clock", gpu.CoreClock.ToString() + " GHz"); break; case (Model.Type.MOTHERBOARD): Motherboard motherboard = db.Motherboards.First(c => c.ItemID == _id); keyValuePairs.Add("Socket", motherboard.Socket); keyValuePairs.Add("Form Factor", motherboard.FormFactor); keyValuePairs.Add("RAM Slots", motherboard.RamSlots.ToString()); keyValuePairs.Add("Max RAM", motherboard.MaxRam); break; case (Model.Type.PSU): PSU psu = db.PSUs.First(c => c.ItemID == _id); keyValuePairs.Add("Series", psu.Series); keyValuePairs.Add("Form", psu.Form); keyValuePairs.Add("Efficiency", psu.Efficiency); keyValuePairs.Add("Watts", psu.Watts.ToString() + " W"); keyValuePairs.Add("Modular", psu.Modular); break; case (Model.Type.RAM): RAM ram = db.RAMs.First(c => c.ItemID == _id); keyValuePairs.Add("Speed", ram.Speed); keyValuePairs.Add("Type", ram.Type); keyValuePairs.Add("CAS", ram.CAS.ToString()); keyValuePairs.Add("Modules", ram.Modules); keyValuePairs.Add("Size", ram.Size); break; default: return(keyValuePairs); } } return(keyValuePairs); } }