public async Task <IActionResult> Edit(int id, [Bind("Numero,Tamanho,Status,IdMatricula,DataPlantio,CodigoCultura")] AreaPlantio areaPlantio) { if (id != areaPlantio.Numero) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(areaPlantio); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AreaPlantioExists(areaPlantio.Numero)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CodigoCultura"] = new SelectList(_context.Culturas, "Codigo", "Nome", areaPlantio.CodigoCultura); ViewData["IdMatricula"] = new SelectList(_context.Funcionarios, "Matricula", "Nome", areaPlantio.IdMatricula); ViewBag.ListaStatus = new SelectList(new AreaPlantio().ListaStatus(), "Status", "Status"); return(View(areaPlantio)); }
public async Task <IActionResult> Create([Bind("Numero,Tamanho,Status,IdMatricula,DataPlantio,CodigoCultura")] AreaPlantio areaPlantio) { if (ModelState.IsValid) { _context.Add(areaPlantio); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CodigoCultura"] = new SelectList(_context.Culturas, "Codigo", "Nome", areaPlantio.CodigoCultura); ViewData["IdMatricula"] = new SelectList(_context.Funcionarios, "Matricula", "Nome", areaPlantio.IdMatricula); ViewBag.ListaStatus = new SelectList(new AreaPlantio().ListaStatus(), "Status", "Status"); return(View(areaPlantio)); }