コード例 #1
0
        public int AgregarRemesas(tbl_remesasDTO remesasDTO)
        {
            int result = 0;

            try
            {
                var MTCN = new SqlParameter

                {
                    ParameterName = "@MTCN",
                    Value         = remesasDTO.MTCN,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };


                var Tipo = new SqlParameter

                {
                    ParameterName = "@Tipo",
                    Value         = remesasDTO.Tipo,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Destinatario1 = new SqlParameter
                {
                    ParameterName = "@Destinatario1",
                    Value         = remesasDTO.Destinatario1 == null ? string.Empty : remesasDTO.Destinatario1,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Destinatario2 = new SqlParameter
                {
                    ParameterName = "@Destinatario2",
                    Value         = remesasDTO.Destinatario2 == null ? string.Empty : remesasDTO.Destinatario2,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Destinatario3 = new SqlParameter
                {
                    ParameterName = "@Destinatario3",
                    Value         = remesasDTO.Destinatario3 == null ? string.Empty : remesasDTO.Destinatario3,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Destinatario4 = new SqlParameter
                {
                    ParameterName = "@Destinatario4",
                    Value         = remesasDTO.Destinatario4 == null ? string.Empty : remesasDTO.Destinatario4,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Destinatario5 = new SqlParameter
                {
                    ParameterName = "@Destinatario5",
                    Value         = remesasDTO.Destinatario5 == null ? string.Empty : remesasDTO.Destinatario5,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Direccion1 = new SqlParameter
                {
                    ParameterName = "@Direccion1",
                    Value         = remesasDTO.Direccion1 == null ? string.Empty : remesasDTO.Direccion1,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Direccion2 = new SqlParameter
                {
                    ParameterName = "@Direccion2",
                    Value         = remesasDTO.Direccion2 == null ? string.Empty : remesasDTO.Direccion2,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var EstadoBeneficiario = new SqlParameter
                {
                    ParameterName = "@EstadoBeneficiario",
                    Value         = remesasDTO.EstadoBeneficiario == null ? string.Empty : remesasDTO.EstadoBeneficiario,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var CiudadBeneficiario = new SqlParameter
                {
                    ParameterName = "@CiudadBeneficiario",
                    Value         = remesasDTO.CiudadBeneficiario == null ? string.Empty : remesasDTO.CiudadBeneficiario,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Telefono = new SqlParameter
                {
                    ParameterName = "@Telefono",
                    Value         = remesasDTO.Telefono == null ? string.Empty : remesasDTO.Telefono,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Identificacion = new SqlParameter
                {
                    ParameterName = "@Identificacion",
                    Value         = remesasDTO.Identificacion == null ? string.Empty : remesasDTO.Identificacion,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var NumeroID = new SqlParameter
                {
                    ParameterName = "@NumeroID",
                    Value         = remesasDTO.NumeroID == null ? string.Empty : remesasDTO.NumeroID,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var EmitidaPor = new SqlParameter
                {
                    ParameterName = "@EmitidaPor",
                    Value         = remesasDTO.EmitidaPor == null ? string.Empty : remesasDTO.EmitidaPor,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };



                var FechaEmision = new SqlParameter
                {
                    ParameterName = "@FechaEmision",
                    Value         = remesasDTO.FechaEmision == null ? string.Empty : remesasDTO.FechaEmision,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var FechaExpiracion = new SqlParameter
                {
                    ParameterName = "@FechaExpiracion",
                    Value         = remesasDTO.FechaExpiracion == null ? string.Empty : remesasDTO.FechaExpiracion,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var FechaNacimiento = new SqlParameter
                {
                    ParameterName = "@FechaNacimiento",
                    Value         = remesasDTO.FechaNacimiento == null ? string.Empty : remesasDTO.FechaNacimiento,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var Ocupacion = new SqlParameter
                {
                    ParameterName = "@Ocupacion",
                    Value         = remesasDTO.Ocupacion == null ? string.Empty : remesasDTO.Ocupacion,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var Nacionalidad = new SqlParameter
                {
                    ParameterName = "@Nacionalidad",
                    Value         = remesasDTO.Nacionalidad == null ? string.Empty : remesasDTO.Nacionalidad,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var Trabajo = new SqlParameter
                {
                    ParameterName = "@Trabajo",
                    Value         = remesasDTO.Trabajo == null ? string.Empty : remesasDTO.Trabajo,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var Sexo = new SqlParameter
                {
                    ParameterName = "@Sexo",
                    Value         = remesasDTO.Sexo == null ? string.Empty : remesasDTO.Sexo,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };


                var EstadoCivil = new SqlParameter
                {
                    ParameterName = "@EstadoCivil",
                    Value         = remesasDTO.EstadoCivil == null ? string.Empty : remesasDTO.EstadoCivil,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var WUCard = new SqlParameter
                {
                    ParameterName = "@WUCard",
                    Value         = remesasDTO.WUCard == null ? string.Empty : remesasDTO.WUCard,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var Remitente1 = new SqlParameter
                {
                    ParameterName = "@Remitente1",
                    Value         = remesasDTO.Remitente1 == null ? string.Empty : remesasDTO.Remitente1,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Remitente2 = new SqlParameter
                {
                    ParameterName = "@Remitente2",
                    Value         = remesasDTO.Remitente2 == null ? string.Empty : remesasDTO.Remitente2,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Remitente3 = new SqlParameter
                {
                    ParameterName = "@Remitente3",
                    Value         = remesasDTO.Remitente3 == null ? string.Empty : remesasDTO.Remitente3,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Remitente4 = new SqlParameter
                {
                    ParameterName = "@Remitente4",
                    Value         = remesasDTO.Remitente4 == null ? string.Empty : remesasDTO.Remitente4,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var Remitente5 = new SqlParameter
                {
                    ParameterName = "@Remitente5",
                    Value         = remesasDTO.Remitente5 == null ? string.Empty : remesasDTO.Remitente5,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };


                var Origen = new SqlParameter
                {
                    ParameterName = "@Origen",
                    Value         = remesasDTO.Origen == null ? string.Empty : remesasDTO.Origen,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };


                var EstadoOrigen = new SqlParameter
                {
                    ParameterName = "@EstadoOrigen",
                    Value         = remesasDTO.EstadoOrigen == null ? string.Empty : remesasDTO.EstadoOrigen,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };


                var CiudadOrigen = new SqlParameter
                {
                    ParameterName = "@CiudadOrigen",
                    Value         = remesasDTO.CiudadOrigen == null ? string.Empty : remesasDTO.CiudadOrigen,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };


                var Fecha = new SqlParameter
                {
                    ParameterName = "@Fecha",
                    Value         = remesasDTO.Fecha == null ? string.Empty : remesasDTO.Fecha,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var Hora = new SqlParameter
                {
                    ParameterName = "@Hora",
                    Value         = remesasDTO.Hora == null ? string.Empty : remesasDTO.Hora,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var Operador = new SqlParameter
                {
                    ParameterName = "@Operador",
                    Value         = remesasDTO.Operador == null ? string.Empty : remesasDTO.Operador,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };



                var Monto = new SqlParameter
                {
                    ParameterName = "@Monto",
                    Value         = remesasDTO.Monto == null ? string.Empty : remesasDTO.Monto,
                    // Precision=15,
                    // Scale=2,
                    SqlDbType = SqlDbType.VarChar,
                    Direction = ParameterDirection.Input
                };

                var Moneda = new SqlParameter
                {
                    ParameterName = "@Moneda",
                    Value         = remesasDTO.Moneda == null ? string.Empty : remesasDTO.Moneda,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var Agente = new SqlParameter
                {
                    ParameterName = "@Agente",
                    Value         = remesasDTO.Agente == null ? string.Empty : remesasDTO.Agente,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var IDTerminal = new SqlParameter
                {
                    ParameterName = "@IDTerminal",
                    Value         = remesasDTO.IDTerminal == null ? string.Empty : remesasDTO.IDTerminal,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var ExchangeRate = new SqlParameter
                {
                    ParameterName = "@ExchangeRate",
                    Value         = remesasDTO.ExchangeRate == null ? string.Empty : remesasDTO.ExchangeRate,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var TestQuestion = new SqlParameter
                {
                    ParameterName = "@TestQuestion",
                    Value         = remesasDTO.TestQuestion == null ? string.Empty : remesasDTO.TestQuestion,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var TestAnswer = new SqlParameter
                {
                    ParameterName = "@TestAnswer",
                    Value         = remesasDTO.TestAnswer == null ? string.Empty : remesasDTO.TestAnswer,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var Mensaje = new SqlParameter
                {
                    ParameterName = "@Mensaje",
                    Value         = remesasDTO.Mensaje == null ? string.Empty : remesasDTO.Mensaje,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var TasaDeCambioFD = new SqlParameter
                {
                    ParameterName = "@TasaDeCambioFD",
                    Value         = remesasDTO.TasaDeCambioFD == null ? string.Empty : remesasDTO.TasaDeCambioFD,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var MonedaOriginalTransaccionTL = new SqlParameter
                {
                    ParameterName = "@MonedaOriginalTransaccionTL",
                    Value         = remesasDTO.MonedaOriginalTransaccionTL == null ? string.Empty : remesasDTO.MonedaOriginalTransaccionTL,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };
                var MontoOriginalTransaccionTL = new SqlParameter
                {
                    ParameterName = "@MontoOriginalTransaccionTL",
                    Value         = remesasDTO.MontoOriginalTransaccionTL == null ? string.Empty : remesasDTO.MontoOriginalTransaccionTL,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };

                var UsuarioCarga = new SqlParameter
                {
                    ParameterName = "@UsuarioCarga",
                    Value         = remesasDTO.UsuarioCarga == null ? string.Empty : remesasDTO.UsuarioCarga,
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Input
                };


                var Salida = new SqlParameter
                {
                    ParameterName = "@Salida",
                    SqlDbType     = SqlDbType.Int,
                    Direction     = ParameterDirection.Output
                };

                var procResult = new SqlParameter
                {
                    ParameterName = "@procResult",
                    SqlDbType     = SqlDbType.Int,
                    Direction     = ParameterDirection.Output
                };

                using (var ctx = new dbContext())
                {
                    var response = ctx.Database.ExecuteSqlCommand("exec @procResult = USPCE_WU_PagosRemesas  @MTCN,@Tipo,@Destinatario1,@Destinatario2,@Destinatario3,@Destinatario4,@Destinatario5,@Direccion1,@Direccion2,@EstadoBeneficiario,@CiudadBeneficiario,@Telefono,@Identificacion,@NumeroID,@EmitidaPor,@FechaEmision,@FechaExpiracion,@FechaNacimiento,@Ocupacion,@Nacionalidad,@Trabajo,@Sexo,@EstadoCivil,@WUCard,@Remitente1,@Remitente2,@Remitente3,@Remitente4,@Remitente5,@Origen,@EstadoOrigen,@CiudadOrigen,@Fecha,@Hora,@Operador,@Monto,@Moneda,@Agente,@IDTerminal,@ExchangeRate,@TestQuestion,@TestAnswer,@Mensaje,@TasaDeCambioFD,@MonedaOriginalTransaccionTL,@MontoOriginalTransaccionTL,@UsuarioCarga,@Salida OUTPUT",
                                                                  new object[]
                                                                  { MTCN, Tipo, Destinatario1, Destinatario2, Destinatario3, Destinatario4, Destinatario5, Direccion1, Direccion2, EstadoBeneficiario, CiudadBeneficiario, Telefono, Identificacion, NumeroID, EmitidaPor, FechaEmision, FechaExpiracion, FechaNacimiento, Ocupacion, Nacionalidad, Trabajo, Sexo, EstadoCivil, WUCard, Remitente1, Remitente2, Remitente3, Remitente4, Remitente5, Origen, EstadoOrigen, CiudadOrigen, Fecha, Hora, Operador, Monto, Moneda, Agente, IDTerminal, ExchangeRate, TestQuestion, TestAnswer, Mensaje, TasaDeCambioFD, MonedaOriginalTransaccionTL, MontoOriginalTransaccionTL, UsuarioCarga, Salida, procResult }
                                                                  );
                    int res0 = (int)Salida.Value;
                    result = res0;



                    int resp = (int)procResult.Value;
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(result);
        }