public void DeleteComponent(GpuDto gpu) { var gpuToDelete = this.context.gpus.FirstOrDefault(c => c.model == gpu.model); this.context.gpus.Remove(gpuToDelete); this.context.SaveChanges(); }
public IActionResult AddGPU(GpuDto gpu) { if (ModelState.IsValid) { this.componentService.CreateGPU(gpu); return(RedirectToAction(nameof(AddGPU))); } return(View(gpu)); }
public IActionResult AddGPU(GpuDto gpu) { if (ModelState.IsValid) { if (componentService.HasTheSameIdInBase(gpu.model)) { return(NotFound("A gpu with the same model already exits")); } this.componentService.CreateGPU(gpu); return(RedirectToAction(nameof(AddGPU))); } return(View(gpu)); }
public Gpu OfGpuDto(GpuDto gpuDto) { return(new Gpu() { model = gpuDto.model, frequency = gpuDto.frequency, vramSpeed = gpuDto.vramSpeed, cores = gpuDto.cores, rtCores = gpuDto.rtCores, memoryQuantity = gpuDto.memoryQuantity, tdp = gpuDto.tdp, SliCrossfireSupport = gpuDto.SliCrossfireSupport, price = gpuDto.price }); }
public GpuDto GetGpuById(string id) { GpuDto gpuDto = new GpuDto(); Gpu gpu = this.context.gpus.FirstOrDefault(x => x.model == id); gpuDto.model = gpu.model; gpuDto.frequency = gpu.frequency; gpuDto.vramSpeed = gpu.vramSpeed; gpuDto.cores = gpu.cores; gpuDto.rtCores = gpu.rtCores; gpuDto.memoryQuantity = gpu.memoryQuantity; gpuDto.tdp = gpu.tdp; gpuDto.SliCrossfireSupport = gpu.SliCrossfireSupport; gpuDto.price = gpu.price; return(gpuDto); }
//public double GetPerformance(CPU cpu, Gpu gpu, RAM ram) //{ // double PerformanceScore = ((cpu.cores * cpu.frequency * 10) - cpu.tdp) // + ((gpu.frequency * gpu.cores) - gpu.tdp + (gpu.rtCores * 2)) + ram.frequency * ram.memorysize; // return PerformanceScore; //} public void CreateGPU(GpuDto gpu) { this.context.gpus.Add(this.OfGpuDto(gpu)); this.context.SaveChanges(); }
public IActionResult DeleteGpu(GpuDto component) { this.componentService.DeleteComponent(component); return(RedirectToAction("ShowGpu", "Gpu")); }