public IActionResult Update([FromBody] Noticias noticia, [FromRoute] int id) { Claim userIdClaim = User.Claims.FirstOrDefault(x => x.Type.Contains("nameIdentifier")); string userId = userIdClaim.Value; try { noticiasCore = new NoticiasCore(db); ResponseApiError responseApiError = noticiasCore.Update(noticia, id, userId); if (responseApiError != null) { return(StatusCode(responseApiError.HttpStatusCode, responseApiError)); } return(Ok(new ResponseApiSuccess { Code = 1, Message = "Noticia modificada" })); } catch (Exception ex) { logger.Error(ex); return(StatusCode((int)HttpStatusCode.InternalServerError, new ResponseApiError { Code = 1001, Message = ex.Message })); } }
public IActionResult Get() { noticiasCore = new NoticiasCore(db); List <Noticias> noticias = noticiasCore.GetAll(); return(Ok(noticias)); }
public IActionResult GetNoticiasUsuario([FromRoute] string username) { noticiasCore = new NoticiasCore(db); List <NoticiasUsuarioView> noticias = noticiasCore.GetNoticiasUsuario(username); return(Ok(noticias)); }
public IActionResult GetNoticiasComentario([FromRoute] int id) { noticiasCore = new NoticiasCore(db); List <NoticiasComentarioView> comentarios = noticiasCore.GetNoticiasComentarios(id); return(Ok(comentarios)); }
public IActionResult Delete([FromRoute] int id) { try { noticiasCore = new NoticiasCore(db); ResponseApiError responseApiError = noticiasCore.Delete(id); if (responseApiError != null) { return(StatusCode(responseApiError.HttpStatusCode, responseApiError)); } return(Ok(new ResponseApiSuccess { Code = 1, Message = "Noticia Eliminada" })); } catch (Exception ex) { logger.Error(ex); return(StatusCode((int)HttpStatusCode.InternalServerError, new ResponseApiError { Code = 1001, Message = ex.Message })); } }