Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "DepartamentoId,Descripcion")] Departamento departamento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(departamento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(departamento));
 }
 public ActionResult Edit([Bind(Include = "EmpleadoID,Nombres,Apellido,Fecha_Ingreso")] Empleado empleado)
 {
     if (ModelState.IsValid)
     {
         db.Entry(empleado).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(empleado));
 }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "RegistroID,Sueldo,DepartamentoID,EmpleadoID")] Registro registro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(registro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartamentoID = new SelectList(db.Departamentos, "DepartamentoID", "Descripcion", registro.DepartamentoID);
     ViewBag.EmpleadoID     = new SelectList(db.Empleados, "EmpleadoID", "Nombres", registro.EmpleadoID);
     return(View(registro));
 }
Exemplo n.º 4
0
        [HttpPut("{id}")]                                                     //Es para modificar
        public async Task <IActionResult> PutEmpleado(long id, Empleado item) //Se usa comunmente para las respuestas que se reciben
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }