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); }
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); }
public int Modificar(InteresSentimental modelo) { return(_adInteresSentimental.Modificar(modelo)); }
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)); }