public void InsertSystemBuild_WithValidData_ShouldInsertRecord() { SetUp(); SetUpComponents(); _systemBuildService.InsertSystemBuild(cpuModel, caseModel, gpuModel, memoryOptionModel, mbModel, storageOptionModel, 123m, "name1", "desc1"); Assert.Contains(_context.SystemBuilds.First(a => a.SystemBuildId == 1), _context.SystemBuilds); }
public IActionResult Create(IFormCollection collection) { string cpuModel = Request.Form["cpus"].ToString(); string caseModel = Request.Form["cases"].ToString(); string gpuModel = Request.Form["gpus"].ToString(); string memoryOptionModel = Request.Form["memoryoptions"].ToString(); string motherboardModel = Request.Form["motherboards"].ToString(); string storageOptionModel = Request.Form["storageoptions"].ToString(); decimal price = decimal.Parse(Request.Form["Price"].ToString()); string name = Request.Form["Name"].ToString(); string description = Request.Form["Description"].ToString(); var image = Request.Form.Files.GetFile("image"); string imgUrl = string.Empty; if (image != null) { imgUrl = _driveService.UploadFile(image); } _service.InsertSystemBuild(cpuModel, caseModel, gpuModel, memoryOptionModel, motherboardModel, storageOptionModel, price, name, description, imgUrl); if (ModelState.IsValid) { return(RedirectToAction(nameof(Index))); } return(View()); }