예제 #1
0
        public IActionResult GetComentarioRespuestas([FromRoute] int id)
        {
            comentariosCore = new ComentariosCore(db);
            List <RespuestasComentarioView> respuestas = comentariosCore.GetRespuestasComentarioViews(id);

            return(Ok(respuestas));
        }
예제 #2
0
        public IActionResult Create([FromBody] Comentarios comentario)
        {
            Claim  userIdClaim = User.Claims.FirstOrDefault(x => x.Type.Contains("nameIdentifier"));
            string userId      = userIdClaim.Value;

            try
            {
                comentariosCore = new ComentariosCore(db);
                ResponseApiError responseApiError = comentariosCore.Create(comentario, userId);

                if (responseApiError != null)
                {
                    return(StatusCode(responseApiError.HttpStatusCode, responseApiError));
                }

                return(Ok(new ResponseApiSuccess {
                    Code = 1, Message = "Comentario posteado"
                }));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(StatusCode((int)HttpStatusCode.InternalServerError, new ResponseApiError {
                    Code = 1001, Message = ex.Message
                }));
            }
        }
예제 #3
0
        public IActionResult Get()
        {
            comentariosCore = new ComentariosCore(db);
            List <Comentarios> comentarios = comentariosCore.GetAll();

            return(Ok(comentarios));
        }
예제 #4
0
 public IEnumerable <Comentarios> GetComentariosPublicacion(int id)
 {
     try
     {
         ComentariosCore comentariosCore = new ComentariosCore(dbContext);
         return(comentariosCore.GetComentariosPublicacion(id));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #5
0
 public IActionResult DesabilitarComentario(int id)
 {
     try
     {
         ComentariosCore comentariosCore = new ComentariosCore(dbContext);
         comentariosCore.DesabilitarComentario(id);
         return(Ok("Comentario Deshabilitado con exito"));
     }
     catch (Exception ex)
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, ex));
     }
 }
예제 #6
0
 public IActionResult CreateComentario([FromBody] Comentarios comentario)
 {
     try
     {
         ComentariosCore comentariosCore = new ComentariosCore(dbContext);
         comentariosCore.CreateComentario(comentario);
         return(Ok("Comentario Agregado"));
     }
     catch (Exception ex)
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, ex));
     }
 }
예제 #7
0
        public IActionResult Delete([FromRoute] int id)
        {
            try
            {
                comentariosCore = new ComentariosCore(db);
                ResponseApiError responseApiError = comentariosCore.Delete(id);

                if (responseApiError != null)
                {
                    return(StatusCode(responseApiError.HttpStatusCode, responseApiError));
                }

                return(Ok(new ResponseApiSuccess {
                    Code = 1, Message = "Comentario Eliminado"
                }));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(StatusCode((int)HttpStatusCode.InternalServerError, new ResponseApiError {
                    Code = 1001, Message = ex.Message
                }));
            }
        }