public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Food_Group,Calories,Fat_g,Protein_g,Carbohydrate_g")] Master_Food master_Food) { if (id != master_Food.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(master_Food); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Master_FoodExists(master_Food.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(master_Food)); }
public async Task <IActionResult> Create([Bind("ID,Name,Food_Group,Calories,Fat_g,Protein_g,Carbohydrate_g")] Master_Food master_Food) { if (ModelState.IsValid) { _context.Add(master_Food); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(master_Food)); }