コード例 #1
0
        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"));
        }
コード例 #2
0
        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 }));
        }
コード例 #3
0
        //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));
                }
            }
        }