Esempio n. 1
0
 public CoPagoViewModel(CoPago coPago)
 {
     Identificacion = coPago.Identificacion;
     Salario        = coPago.Salario;
     ValorServicio  = coPago.ValorServicio;
     Tarifa         = coPago.Tarifa;
     Valor          = coPago.Valor;
 }
Esempio n. 2
0
        public CoPagoResponse Guardar(CoPago coPago)
        {
            try
            {
                _conexion.Open();
                _repositorio.Guardar(coPago);

                _conexion.Close();
                return(new CoPagoResponse(coPago));
            }
            catch (Exception e)
            {
                return(new CoPagoResponse($"Error de aplicacion: {e.Message}"));
            }
            finally { _conexion.Close(); }
        }
Esempio n. 3
0
        public CoPagoViewModel Insert([FromBody] CoPagoInputModel model)
        {
            CoPago copago = new CoPago()
            {
                Identificacion = model.Identificacion,
                Salario        = model.Salario,
                ValorServicio  = model.ValorServicio
            };
            CoPagoResponse response = coPagoService.Guardar(copago);

            if (response.Error)
            {
                return(null);
            }
            return(new CoPagoViewModel(response.CoPago));
        }
Esempio n. 4
0
        private CoPago DataReaderMapToPerson(SqlDataReader dataReader)
        {
            if (!dataReader.HasRows)
            {
                return(null);
            }
            CoPago coPago = new CoPago();

            coPago.Identificacion = (string)dataReader["Identificacion"];
            float salario = (float)dataReader["Salario"];

            coPago.Salario = (decimal)salario;
            float valorServicio = (float)dataReader["ValorServicio"];

            coPago.ValorServicio = (decimal)valorServicio;
            return(coPago);
        }
Esempio n. 5
0
        public List <CoPago> ConsultarTodos()
        {
            SqlDataReader dataReader;
            List <CoPago> coPagos = new List <CoPago>();

            using (var command = _connection.CreateCommand())
            {
                command.CommandText = "Select * from LiquidacionesTable ";
                dataReader          = command.ExecuteReader();
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        CoPago coPago = DataReaderMapToPerson(dataReader);
                        coPagos.Add(coPago);
                    }
                }
            }
            return(coPagos);
        }
Esempio n. 6
0
 public bool Guardar(CoPago coPago)
 {
     using (var command = _connection.CreateCommand())
     {
         command.CommandText = @"Insert Into LiquidacionesTable (Identificacion,Salario,ValorServicio,Tarifa,Valor) 
                                 values (@Identificacion,@Salario,@ValorServicio,@Tarifa,@Valor)";
         command.Parameters.AddWithValue("@Identificacion", coPago.Identificacion);
         command.Parameters.AddWithValue("@Salario", coPago.Salario);
         command.Parameters.AddWithValue("@ValorServicio", coPago.ValorServicio);
         command.Parameters.AddWithValue("@Tarifa", coPago.Tarifa);
         command.Parameters.AddWithValue("@Valor", coPago.Valor);
         int filas = command.ExecuteNonQuery();
         if (filas > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 7
0
 public CoPagoResponse(CoPago coPago)
 {
     Error  = false;
     CoPago = coPago;
 }