コード例 #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            Comment comment = new Comment(); // acest tip este vazut in serviciu
            int     postId  = 0;

            postId             = id.Value;
            comment.PostPostId = postId;
            comment.Text       = CommentDTO.Text;
            var result = await pcc.AddCommentAsync(comment);

            if (!result)
            {
                return(RedirectToAction("Error"));
            }
            return(RedirectToPage("/Posts/Index"));
        }
コード例 #2
0
        public async Task <IActionResult> OnPostAsync(Guid?id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var comment = new Comment
            {
                PostPostId = id.Value,
                Text       = CommentDTO.Text
            };

            var result = await pcc.AddCommentAsync(comment);

            if (!result)
            {
                return(RedirectToAction("Error"));
            }

            return(RedirectToPage("/Posts/Index"));
        }