コード例 #1
0
        public void UpdateSystemBuild_WithValidData_ShouldUpdateRecord()
        {
            SetUp();
            SeedData();
            SetUpComponents();
            _systemBuildService.Update(cpuModel, caseModel, gpuModel, memoryOptionModel, mbModel, storageOptionModel, "name2", "desc2", 1);

            Assert.Equal("name2", _context.SystemBuilds.First(a => a.SystemBuildId == 1).Name);
        }
コード例 #2
0
        public IActionResult Edit(int id, [Bind("SystemBuildId,Price")] SystemBuild systemBuild)
        {
            if (id != systemBuild.SystemBuildId)
            {
                return(NotFound());
            }

            string cpuModel           = Request.Form["cpus"].ToString();
            string caseModel          = Request.Form["cases"].ToString();
            string gpuModel           = Request.Form["gpus"].ToString();
            string memoryOptionModel  = Request.Form["memoryoption"].ToString();
            string motherboardModel   = Request.Form["motherboards"].ToString();
            string storageOptionModel = Request.Form["storageoption"].ToString();

            string name        = Request.Form["Name"].ToString();
            string description = Request.Form["Description"].ToString();

            if (ModelState.IsValid)
            {
                var    image    = Request.Form.Files.GetFile("image");
                string imageUrl = string.Empty;
                if (image != null)
                {
                    _driveService.DeleteFile(Request.Form["ImgUrl"]);
                    imageUrl = _driveService.UploadFile(image);
                }
                else
                {
                    imageUrl = Constants.DEFAULT_BUILD_IMG;
                }

                _service.Update(cpuModel, caseModel, gpuModel, memoryOptionModel, motherboardModel, storageOptionModel, name, description, id, imageUrl);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(systemBuild));
        }