Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("EmpleadoID,Codigo_Empleado,Cedula,Nombre,Apellido,Fecha_Ingreso,Ocupacion")] Empleado empleado)
        {
            if (id != empleado.EmpleadoID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(empleado);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmpleadoExists(empleado.EmpleadoID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(empleado));
        }
        public async Task <bool> ActualizarEmpleado(int id_empleado, Empleado empleado)
        {
            bool response = false;

            try {
                empleado.id_empleado = id_empleado;
                empleadoContext.Update(empleado);
                await empleadoContext.SaveChangesAsync();

                response = true;
            }
            catch (Exception exception) {
                ShowExceptionMessage(exception);
            }
            return(response);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> AddOrEdit([Bind("EmpID,Cedula,Nombre,Puesto,Salario")] Empleado empleado)
        {
            if (ModelState.IsValid)
            {
                if (empleado.EmpID == 0)
                {
                    _context.Add(empleado);
                }
                else
                {
                    _context.Update(empleado);
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(empleado));
        }