public async Task <IActionResult> Edit(int id, [Bind("PiantaID,Produttivita")] Frutta frutta) { if (id != frutta.PiantaID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(frutta); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FruttaExists(frutta.PiantaID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PiantaID"] = new SelectList(_context.Piante, "Id", "Nome", frutta.PiantaID); return(View(frutta)); }
public async Task <IActionResult> Create([Bind("PiantaID,Produttivita")] Frutta frutta) { if (ModelState.IsValid) { _context.Add(frutta); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PiantaID"] = new SelectList(_context.Piante, "Id", "Nome", frutta.PiantaID); return(View(frutta)); }