public async Task <IActionResult> Create( [Bind("ID,PveDataID,GroupName,TestGroup,ActualTestDate,SoftVersion,SABVersion,Remark")] J2TestData j2TestData, int?foreignKey) { if (!ModelState.IsValid) { return(View(j2TestData)); } if (!GetPveData(foreignKey, out var pveData)) { return(RedirectToAction("Index", "PveDatas")); } j2TestData.PveData = pveData; _context.Add(j2TestData); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { foreignKey = pveData.ID })); }
public async Task <IActionResult> Edit( int id, [Bind("ID,PveDataID,GroupName,TestGroup,ActualTestDate,SoftVersion,SABVersion,Remark")] J2TestData j2TestData, int?foreignKey) { if (id != j2TestData.ID) { return(NotFound()); } if (!GetPveData(foreignKey, out _)) { return(RedirectToAction("Index", "PveDatas")); } if (ModelState.IsValid) { try { _context.Update(j2TestData); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!J2TestDataExists(j2TestData.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index), new { foreignKey })); } return(View(j2TestData)); }