Пример #1
0
        public HttpResponseMessage GetCommentReplies()
        {
            ItemsResponse <CommentAdvanced> response = new ItemsResponse <CommentAdvanced>();

            response.Items = CommentReplyService.CommentReplySelect();

            return(Request.CreateResponse(response));
        } //GetCommentReplies
Пример #2
0
        public HttpResponseMessage GetCommentReplyById([FromUri] int commentReplyId)
        {
            if (commentReplyId <= 0)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            ItemResponse <CommentAdvanced> response = new ItemResponse <CommentAdvanced>();

            response.Item = CommentReplyService.CommentReplySelectById(commentReplyId);

            return(Request.CreateResponse(response));
        } //GetCommentReplyById
Пример #3
0
        public HttpResponseMessage GetCommentRepliesByCommentId([FromUri] int commentId)
        {
            if (commentId <= 0)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            ItemsResponse <CommentAdvanced> response = new ItemsResponse <CommentAdvanced>(); // pass the list Replies into response

            response.Items = CommentReplyService.CommentReplySelectByCommentId(commentId);

            return(Request.CreateResponse(response));
        } //GetCommentRepliesByCommentId
Пример #4
0
        [HttpDelete] // <== type of http methods supported
        public HttpResponseMessage DeleteCommentReply([FromUri] int commentReplyId)
        {
            if (commentReplyId <= 0)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            // create our response model
            SuccessResponse response = new SuccessResponse();

            CommentReplyService.CommentReplyDelete(commentReplyId);

            return(Request.CreateResponse(response));
        } // DeleteCommentReply
Пример #5
0
        public HttpResponseMessage CreateCommentReply([FromBody] CommentReplyAddRequest payload)
        {
            if (string.IsNullOrWhiteSpace(payload.Title) ||
                string.IsNullOrWhiteSpace(payload.Content) ||
                string.IsNullOrWhiteSpace(payload.Author) ||
                payload.ParentCommentId <= 0)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            // create our response model
            ItemResponse <int> response = new ItemResponse <int>();

            response.Item = CommentReplyService.CommentReplyInsert(payload.ParentCommentId, payload.Author, payload.Title, payload.Content);

            return(Request.CreateResponse(response));
        } //CreateCommentReply
Пример #6
0
        [HttpPut] // <== type of http methods supported
        public HttpResponseMessage UpdateCommentReply([FromUri] int id, [FromBody] CommentReplyUpdateRequest payload)
        {
            if (string.IsNullOrWhiteSpace(payload.Title) ||
                string.IsNullOrWhiteSpace(payload.Content) ||
                string.IsNullOrWhiteSpace(payload.Author) ||
                payload.ParentCommentId <= 0 ||
                id <= 0)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            // create our response model
            SuccessResponse response = new SuccessResponse();

            CommentReplyService.CommentReplyUpdate(payload.id, payload.Title, payload.Content);

            return(Request.CreateResponse(response));
        } // UpdateCommentReply