コード例 #1
0
        public IHttpActionResult PostEMPLEADO(View_EmpleadoPorRol empleado)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string contrasenia = empleado.Contrasena;
            string cedula      = empleado.Cedula;
            string nombre      = empleado.Nombre;
            string apellidos   = empleado.Apellidos;
            byte   Rol         = empleado.IdRol;
            //calls an insert stored procedure and returns the new id
            var idNew = db.sp_insert_Empleado(contrasenia, cedula, nombre, apellidos, Rol);

            empleado.IdEmpleado = idNew.SingleOrDefault().Value;
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (Empleado_Por_Rol_Exists(empleado.IdEmpleado))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(empleado));
        }
コード例 #2
0
        public IHttpActionResult GetEMPLEADO_POR_ROL(int idEmpleado, int idRol)
        {
            View_EmpleadoPorRol Empleado = db.View_EmpleadoPorRol.
                                           SqlQuery("Select * from View_EmpleadoPorRol where idEmpleado = '" + idEmpleado + "' and idRol = '" + idRol + "' ").ToList().First();

            if (Empleado == null || Empleado.Estado != "A")
            {
                return(NotFound());
            }

            return(Ok(Empleado));
        }