public int Registrar(InteresSentimentalRegistrarDto modelo, ref int idNuevo)
        {
            int resultado = 0;

            try
            {
                const string query = "Maestro.usp_InteresSentimental_Registrar";

                var p = new DynamicParameters();
                p.Add("IdInteresSentimental", 0, DbType.Int32, ParameterDirection.Output);
                p.Add("Descripcion", modelo.Descripcion);

                using (var cn = HelperClass.ObtenerConeccion())
                {
                    if (cn.State == ConnectionState.Closed)
                    {
                        cn.Open();
                    }

                    resultado = cn.Execute(query, commandType: CommandType.StoredProcedure, param: p);

                    idNuevo = p.Get <int>("IdInteresSentimental");
                }
            }
            catch (Exception ex)
            {
                Log(Level.Error, (ex.InnerException == null ? ex.Message : ex.InnerException.Message));
            }
            return(resultado);
        }
Exemple #2
0
 public int Registrar(InteresSentimentalRegistrarDto modelo, ref int idNuevo)
 {
     return(_adInteresSentimental.Registrar(modelo, ref idNuevo));
 }
Exemple #3
0
        public async Task <ActionResult <InteresSentimentalResponseRegistrarDto> > Registrar([FromBody] InteresSentimentalRegistrarDto modelo)
        {
            InteresSentimentalResponseRegistrarDto respuesta = new InteresSentimentalResponseRegistrarDto();

            if (!ModelState.IsValid)
            {
                respuesta.ListaError.Add(new ErrorDto {
                    Mensaje = "Los parametros enviados no son correctos"
                });
                return(BadRequest(respuesta));
            }

            int nuevoId = 0;
            var result  = await Task.FromResult(_lnInteresSentimental.Registrar(modelo, ref nuevoId));

            if (result == 0)
            {
                respuesta.ListaError.Add(new ErrorDto {
                    Mensaje = "Error al intentar registrar"
                });
                return(BadRequest(respuesta));
            }

            respuesta.ProcesadoOk = true;
            respuesta.IdGenerado  = nuevoId;

            return(Ok(respuesta));
        }