Beispiel #1
0
        public async Task <Comment> Create_SubComment([FromBody] InsertSubComment comment)
        {
            if (ModelState.IsValid)
            {
                Owner  owner           = um.GetUser_Cookie(Request);
                string decoded_post_id = _helper.DecodeFrom64(comment.post_id);
                if (comment.sub_post_id != null)
                {
                    await pm.increase_sub_post_sub_comment_countAsync(decoded_post_id, _helper.DecodeFrom64(comment.sub_post_id), 1);

                    decoded_post_id = _helper.DecodeFrom64(comment.sub_post_id);
                }
                else
                {
                    await pm.increase_sub_commentsAsync(decoded_post_id, 1);
                }
                string  decoded_parent_comment_id = _helper.DecodeFrom64(comment.parent_comment_id);
                Comment c = await cm.insert_subCommentAsync(decoded_post_id, decoded_parent_comment_id, new Comment
                {
                    message      = comment.reply_text,
                    date_created = DateTime.Now,
                    owner        = owner
                });

                c.has_like = "none";
                c.is_own   = true;
                c._id      = _helper.EncodeTo64(c._id);
                await cm.update_comment_count(decoded_post_id, decoded_parent_comment_id, 1);

                return(c);
            }
            else
            {
                return(null);
            }
        }