public CoPagoViewModel(CoPago coPago) { Identificacion = coPago.Identificacion; Salario = coPago.Salario; ValorServicio = coPago.ValorServicio; Tarifa = coPago.Tarifa; Valor = coPago.Valor; }
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(); } }
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)); }
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); }
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); }
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); } } }
public CoPagoResponse(CoPago coPago) { Error = false; CoPago = coPago; }