Exemplo n.º 1
0
        public int Modificar(InteresSentimental modelo)
        {
            int resultado = 0;

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

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

                    resultado = cn.Execute(query, new
                    {
                        modelo.IdInteresSentimental,
                        modelo.Descripcion
                    }, commandType: CommandType.StoredProcedure);
                }
            }
            catch (Exception ex)
            {
                Log(Level.Error, (ex.InnerException == null ? ex.Message : ex.InnerException.Message));
            }
            return(resultado);
        }
Exemplo n.º 2
0
        public InteresSentimental ObtenerPorId(int id)
        {
            InteresSentimental resultado = new InteresSentimental();

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

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

                    resultado = cn.QuerySingleOrDefault <InteresSentimental>(query, new
                    {
                        IdInteresSentimental = id
                    }, commandType: CommandType.StoredProcedure);
                }
            }
            catch (Exception ex)
            {
                Log(Level.Error, (ex.InnerException == null ? ex.Message : ex.InnerException.Message));
            }
            return(resultado);
        }
Exemplo n.º 3
0
 public int Modificar(InteresSentimental modelo)
 {
     return(_adInteresSentimental.Modificar(modelo));
 }
Exemplo n.º 4
0
        public async Task <ActionResult <InteresSentimentalResponseModificarDto> > Modificar(int id, [FromBody] InteresSentimental modelo)
        {
            InteresSentimentalResponseModificarDto respuesta = new InteresSentimentalResponseModificarDto();

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

            var entidad = await Task.FromResult(_lnInteresSentimental.ObtenerPorId(modelo.IdInteresSentimental));

            if (entidad == null)
            {
                respuesta.ListaError.Add(new ErrorDto {
                    Mensaje = "Objeto no encontrado con el ID proporcionado"
                });
                return(NotFound(respuesta));
            }

            var result = await Task.FromResult(_lnInteresSentimental.Modificar(modelo));

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

            respuesta.ProcesadoOk = true;
            return(Ok(respuesta));
        }