public async Task <IActionResult> Edit(int id, [Bind("ReporteAccidenteId,Accidente,Comentarios,Fecha,EmpleadoId")] ReporteAccidente reporteAccidente) { if (id != reporteAccidente.ReporteAccidenteId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(reporteAccidente); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReporteAccidenteExists(reporteAccidente.ReporteAccidenteId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmpleadoId"] = new SelectList(_context.Empleados, "EmpleadoId", "Nombre", reporteAccidente.EmpleadoId); return(View(reporteAccidente)); }
public async Task <IActionResult> Create([Bind("ReporteAccidenteId,Accidente,Comentarios,Fecha,EmpleadoId")] ReporteAccidente reporteAccidente) { if (ModelState.IsValid) { _context.Add(reporteAccidente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmpleadoId"] = new SelectList(_context.Empleados, "EmpleadoId", "Nombre", reporteAccidente.EmpleadoId); return(View(reporteAccidente)); }