Exemple #1
0
        public void Update_WithExistingCpu_ShouldUpdateCpu()
        {
            SetUp();

            SeedData();
            var cpu = _context.Cpus.First();

            cpu.Model = "123";
            _cpuService.Update(cpu);

            Assert.Equal(cpu, _context.Cpus.First());
        }
Exemple #2
0
        public IActionResult Edit(int id, [Bind("CpuId,Model,Price,Manufacturer,Socket,NumberOfCores,CacheMemory")] Cpu cpu)
        {
            if (id != cpu.CpuId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                _driveService.DeleteFile(Request.Form["ImgUrl"]);
                var image = Request.Form.Files.GetFile("image");
                if (image != null)
                {
                    cpu.ImgUrl = _driveService.UploadFile(image);
                }
                _service.Update(cpu);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cpu));
        }