public async Task <IActionResult> Edit(int id, [Bind("IdProduct,ProductName,MaterialNameId,NumberOfMaterialsPerItem,ProductPrice")] Product product) { if (id != product.IdProduct) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); _cachedService.RefreshProducts(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.IdProduct)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaterialNameId"] = new SelectList(_context.Materials, "IdMaterial", "MaterialName", product.MaterialNameId); return(View(product)); }