public ActionResult AddToShoppingCart(int ID) { IntelCPU intelCPU = db.IntelCPUs.Find(ID); ShoppingCart basket = new ShoppingCart(); basket.AddItem(new Parts { Name = ("Intel Core " + (intelCPU.Core) + " " + (intelCPU.Model)), Price = (intelCPU.Price), ID = IdSetter.setId() }); basket.DisplayFor(IdSetter.setId()); IdSetter.incrementId(); //seed++; return(RedirectToAction("Index")); }
public ComputerModel GetAllData() { computer.Open(); computer.CpuEnabled = true; computer.MainboardEnabled = true; computer.RAMEnabled = true; computer.GPUEnabled = true; hardware = computer.Hardware; CpuModel[] cpus = new CpuModel[] { }; var hwd = hardware.OfType <GenericCPU>().ToArray(); var hwCpus = hwd.OfType <GenericCPU>(); var hwBios = hardware.OfType <Mainboard>()?.FirstOrDefault()?.BIOS; cpus = hwCpus.Select(cp => { var l1CacheData = cp.Caches.ContainsKey(CacheLevels.Level1) ? cp.Caches[CacheLevels.Level1].FirstOrDefault(ch => ch.CacheType == CacheType.Data) : null; var l1CacheInstructions = cp.Caches.ContainsKey(CacheLevels.Level1) ? cp.Caches[CacheLevels.Level1].FirstOrDefault(ch => ch.CacheType == CacheType.Instructions) : null; var l2Cache = cp.Caches.ContainsKey(CacheLevels.Level2) ? cp.Caches[CacheLevels.Level2].FirstOrDefault() : null; var l3Cache = cp.Caches.ContainsKey(CacheLevels.Level3) ? cp.Caches[CacheLevels.Level3].FirstOrDefault() : null; IntelCPU intelCpu = cp as IntelCPU; var specificCpu = (intelCpu != null) ? intelCpu : ((cp is AMDCPU amdCPu) ? amdCPu : cp); var cpuModel = new CpuModel() { Architecture = ArchitectureHelper.GetArchitecture((uint)(specificCpu.Is64bit ? 9 : 0), 0), Name = specificCpu.Name, CodeName = specificCpu.CodeName, Specification = cp.BrandString, NumberOfCores = (uint)cp.Cores, NumberOfLogicalProcessors = (uint)cp.Threads, Technology = cp.Technology, CpuClocks = new CpuClocks() { }, CpuFamilyModelStepping = new CpuFamilyModelStepping() { FullFamily = (byte)cp.Family, Family = (byte)cp.FamilyId, FullModel = (byte)cp.Model, Stepping = (byte)cp.Stepping, }, Instructions = GetInstructions(specificCpu, cp.InstructionsExtensions), Caches = new CpuCaches() { Level1Data = l1CacheData != null ? new CpuCacheItem() { Level = 1, Associativity = (byte)l1CacheData.Associativity, Size = l1CacheData.SizeKbytes * 1024, LineSize = l1CacheData.LineSize, NumberOfCores = (uint)cp.Cores } : new CpuCacheItem() { }, Level1Instructions = l1CacheInstructions != null ? new CpuCacheItem() { Level = 1, Associativity = (byte)l1CacheInstructions.Associativity, Size = l1CacheInstructions.SizeKbytes * 1024, LineSize = l1CacheInstructions.LineSize, NumberOfCores = (uint)cp.Cores } : new CpuCacheItem() { }, Level2 = l2Cache != null ? new CpuCacheItem() { Level = 2, Associativity = (byte)l2Cache.Associativity, Size = l2Cache.SizeKbytes * 1024, LineSize = l2Cache.LineSize, NumberOfCores = (uint)cp.Cores } : new CpuCacheItem() { }, Level3 = l3Cache != null ? new CpuCacheItem() { Level = 3, Associativity = (byte)l3Cache.Associativity, LineSize = l3Cache.LineSize, Size = l3Cache.SizeKbytes * 1024 } : new CpuCacheItem() { }, } }; SetCpuClocks(cp, hwBios, cpuModel.CpuClocks); return(cpuModel); }).ToArray(); Motherboard motherboard = null; if (hwBios != null && hwBios.Board != null) { motherboard = new Motherboard() { Manufacturer = hwBios.Board.ManufacturerName, Model = hwBios.Board.ProductName, Version = hwBios.Board.Version }; } else { motherboard = new Motherboard() { Manufacturer = string.Empty, Model = string.Empty, Version = string.Empty }; } Bios bios = null; if (hwBios != null && hwBios.BIOS != null) { bios = new Bios() { Brand = hwBios.BIOS.Vendor, Date = hwBios.BIOS.Date, Version = hwBios.BIOS.Version }; } else { bios = new Bios() { Brand = string.Empty, Date = string.Empty, Version = string.Empty }; } return(new ComputerModel() { Cpus = new AllCpus() { Cpus = cpus, RootCpu = cpus?[0], TotalOfCores = cpus.Length > 1 ? (uint)cpus.Sum(c => c.NumberOfCores) : (cpus?[0]?.NumberOfCores ?? 0), TotalOfLogicalProcessors = cpus.Length > 1 ? (uint)cpus.Sum(c => c.NumberOfLogicalProcessors) : (cpus?[0]?.NumberOfLogicalProcessors ?? 0), }, Motherboard = motherboard, Bios = bios }); }