public ActionResult AddCpu(int cpuId) { var cp = new CpuRepo(new CpuMssql()); var pc = (Computer)Session["CurrentBuild"]; pc.Cpu = cp.GetById(cpuId); Session["CurrentBuild"] = pc; return(RedirectToAction("NewBuild", "Build")); }
public ActionResult EditCpu(int computerId, int cpuId) { var cr = new ComputerRepo(new ComputerMssql()); var cp = new CpuRepo(new CpuMssql()); var editedPc = cr.GetById(computerId); editedPc.Cpu = cp.GetById(cpuId); cr.Update(editedPc); return(RedirectToAction("EditBuild", "Build", new { computerId })); }
//constructor public Computer(int computerId, int cpuId, int motherboardId, int memoryId, int storageId, List <int> gpus) { Gpus = new List <Gpu>(); ComputerId = computerId; Cpu = cpuRepo.GetById(Convert.ToInt16(cpuId)); Motherboard = motherboardRepo.GetById(motherboardId); Memory = memoryRepo.GetById(memoryId); Storage = storageRepo.GetById(storageId); foreach (var gpu in gpus) { if (gpuRepo.GetById(gpu) != null) { Gpus.Add(gpuRepo.GetById(gpu)); } } }