Example #1
0
        public List <PuestoDTO> Listar(PuestoDTO entity)
        {
            List <PuestoDTO> retval = new List <PuestoDTO>();
            PuestoDTO        item;

            using (DbCommand cmd = db.GetStoredProcCommand("sp_sel_puestos"))
            {
                db.AddInParameter(cmd, "acEstado", DbType.String, entity.Estado);
                db.AddInParameter(cmd, "avFiltro", DbType.String, entity.Nombre);
                using (IDataReader dr = db.ExecuteReader(cmd))
                {
                    while (dr.Read())
                    {
                        item                 = new PuestoDTO();
                        item.Id              = int.Parse(dr["Id"].ToString());
                        item.Nombre          = dr["Nombre"].ToString();
                        item.Descripcion     = dr["Descripcion"].ToString();
                        item.Estado          = dr["Estado"].ToString();
                        item.UsuarioCreacion = dr["Usuario_Creacion"].ToString();
                        retval.Add(item);
                    }
                }
            }
            return(retval);
        }
        public async Task <ActionResult> pvwAddPuesto([FromBody] PuestoDTO _sarpara)
        {
            PuestoDTO _Puesto = new PuestoDTO();

            try
            {
                string     baseadress = config.Value.urlbase;
                HttpClient _client    = new HttpClient();
                _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token"));
                var result = await _client.GetAsync(baseadress + "api/Puesto/GetPuestoById/" + _sarpara.IdPuesto);

                string valorrespuesta = "";
                if (result.IsSuccessStatusCode)
                {
                    valorrespuesta = await(result.Content.ReadAsStringAsync());
                    _Puesto        = JsonConvert.DeserializeObject <PuestoDTO>(valorrespuesta);
                }

                if (_Puesto == null)
                {
                    _Puesto = new PuestoDTO();
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                throw ex;
            }



            return(PartialView(_Puesto));
        }
Example #3
0
 public void Obtener()
 {
     using (HttpClient httpclient = new HttpClient())
     {
         httpclient.BaseAddress = new Uri("http://localhost:19560/PuestoService.svc/15");
         HttpResponseMessage response = httpclient.GetAsync(httpclient.BaseAddress).Result;
         response.EnsureSuccessStatusCode();
         PuestoDTO puestoDTO = response.Content.ReadAsAsync <PuestoDTO>().Result;
         Assert.AreEqual(15, puestoDTO.Id);
     }
 }
Example #4
0
 public int Insertar(PuestoDTO entity)
 {
     try
     {
         return(bPuesto.Insertar(entity));
     }
     catch (Exception ex)
     {
         throw new WebFaultException <FaultDTO>(new FaultDTO {
             FaultId = "-99", FaultDescription = ex.Message
         }, System.Net.HttpStatusCode.InternalServerError);
     }
 }
Example #5
0
 public static PuestoModel AsModel(this PuestoDTO dto)
 {
     return(new PuestoModel
     {
         Id = dto.Id,
         Nombre = dto.Nombre,
         Descripcion = dto.Descripcion,
         Accion = dto.Accion,
         UsuarioCreacion = dto.UsuarioCreacion,
         FechaCreacion = dto.FechaCreacion,
         UsuarioModificacion = dto.UsuarioModificacion,
         FechaModificacion = dto.FechaModificacion
     });
 }
Example #6
0
 public int Actualizar(string id, PuestoDTO entity)
 {
     try
     {
         entity.Id = int.Parse(id);
         return(bPuesto.Actualizar(entity));
     }
     catch (Exception ex)
     {
         throw new WebFaultException <FaultDTO>(new FaultDTO {
             FaultId = "-99", FaultDescription = ex.Message
         }, System.Net.HttpStatusCode.InternalServerError);
         //throw new FaultException<FaultDTO>(new FaultDTO { FaultId = "-99", FaultDescription = ex.Message }, new FaultReason(ex.Message));
     }
 }
Example #7
0
        public void Actualizar()
        {
            using (HttpClient httpclient = new HttpClient())
            {
                httpclient.BaseAddress = new Uri("http://localhost:19560/PuestoService.svc/15");
                HttpResponseMessage response = httpclient.PutAsJsonAsync(httpclient.BaseAddress, new PuestoDTO
                {
                    Nombre = "Analista Junior .NET qqqq Test"
                }).Result;

                response = httpclient.GetAsync(httpclient.BaseAddress).Result;
                response.EnsureSuccessStatusCode();
                PuestoDTO puestoDTO = response.Content.ReadAsAsync <PuestoDTO>().Result;
                Assert.AreEqual("Analista Junior .NET qqqq Test", puestoDTO.Nombre);
            }
        }
        public void createPuestoReport()
        {
            var puestoData = new CD_Puesto();
            var result     = puestoData.Mostar();

            puestoLista = new List <PuestoDTO>();
            foreach (System.Data.DataRow row in result.Rows)
            {
                var re = new PuestoDTO()
                {
                    Id            = Convert.ToInt32((row[0])),
                    Nombre        = Convert.ToString(row[1]),
                    MinimoSalario = Convert.ToDouble(row[2]),
                    MaximoSalario = Convert.ToDouble(row[3]),
                    Estatus       = Convert.ToInt32(row[4])
                };
                puestoLista.Add(re);
            }
        }
Example #9
0
 private int EjecutarMantenimiento(PuestoDTO entity, int accion)
 {
     using (DbCommand cmd = db.GetStoredProcCommand("sp_reg_puestos"))
     {
         db.AddInParameter(cmd, "aitype", DbType.Int16, accion);
         db.AddInParameter(cmd, "aiId", DbType.Int32, entity.Id);
         db.AddInParameter(cmd, "avNombre", DbType.String, entity.Nombre);
         db.AddInParameter(cmd, "avDescripcion", DbType.String, entity.Descripcion);
         db.AddInParameter(cmd, "avUsuario_Creacion", DbType.String, entity.UsuarioCreacion);
         db.AddInParameter(cmd, "avUsuario_Modificacion", DbType.String, entity.UsuarioModificacion);
         db.AddInParameter(cmd, "avConocimientoTecnico", DbType.String, entity.ConocimientoTecnico);
         if (accion == 1)
         {
             return(int.Parse(db.ExecuteScalar(cmd).ToString()));
         }
         else
         {
             db.ExecuteNonQuery(cmd);
             return(entity.Id);
         }
     }
 }
Example #10
0
        public PuestoDTO Obtener(PuestoDTO entity)
        {
            PuestoDTO item = null;

            using (DbCommand cmd = db.GetStoredProcCommand("sp_sel_puesto_por_id"))
            {
                db.AddInParameter(cmd, "aiId", DbType.String, entity.Id);
                using (IDataReader dr = db.ExecuteReader(cmd))
                {
                    if (dr.Read())
                    {
                        item                     = new PuestoDTO();
                        item.Id                  = int.Parse(dr["Id"].ToString());
                        item.Estado              = dr["Estado"].ToString();
                        item.Nombre              = dr["Nombre"].ToString();
                        item.Descripcion         = dr["Descripcion"].ToString();
                        item.ConocimientoTecnico = dr["Conocimiento_Tecnico"].ToString();
                    }
                }
            }
            return(item);
        }
Example #11
0
 public int Insertar(PuestoDTO entity)
 {
     return(EjecutarMantenimiento(entity, 1));
 }
Example #12
0
 public int Eliminar(PuestoDTO entity)
 {
     return(EjecutarMantenimiento(entity, 3));
 }
Example #13
0
 public int ActualizarEstado(PuestoDTO entity)
 {
     throw new NotImplementedException();
 }
Example #14
0
 public int Actualizar(PuestoDTO entity)
 {
     return(EjecutarMantenimiento(entity, 2));
 }
Example #15
0
 public List <PuestoDTO> Listar(PuestoDTO entity)
 {
     return(daPuesto.Listar(entity));
 }
Example #16
0
 public int Eliminar(PuestoDTO entity)
 {
     return(daPuesto.Eliminar(entity));
 }
Example #17
0
 public int Actualizar(PuestoDTO entity)
 {
     return(daPuesto.Actualizar(entity));
 }
Example #18
0
 public int Insertar(PuestoDTO entity)
 {
     return(daPuesto.Insertar(entity));
 }
Example #19
0
 public PuestoDTO Obtener(PuestoDTO entity)
 {
     return(daPuesto.Obtener(entity));
 }