public async Task <IActionResult> Edit(int id, [Bind("ProductId,ProductName,ProductOwner,ProductCategoryId")] PtsProduct ptsProduct) { if (id != ptsProduct.ProductId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(ptsProduct); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PtsProductExists(ptsProduct.ProductId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductCategoryId"] = new SelectList(_context.PtsProductCategory, "ProductCategoryId", "ProductCategoryName", ptsProduct.ProductCategoryId); return(View(ptsProduct)); }
public async Task <IActionResult> Create([Bind("ProductId,ProductName,ProductOwner,ProductCategoryId")] PtsProduct ptsProduct) { if (ModelState.IsValid) { _context.Add(ptsProduct); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProductCategoryId"] = new SelectList(_context.PtsProductCategory, "ProductCategoryId", "ProductCategoryName", ptsProduct.ProductCategoryId); return(View(ptsProduct)); }