public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,CreatedDate")] Category category) { if (id != category.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Price,Quantity,CategoryId,Ingredients")] Food food) { if (id != food.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(food); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FoodExists(food.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "Id", food.CategoryId); return(View(food)); }