public async Task <IActionResult> OnPostAsync(int?id) { if (!ModelState.IsValid) { return(Page()); } initialComment = await pcc.GetCommentByIdAsync(id.Value); comment.CommentId = id.Value; CommentDTO c = await pcc.UpdateCommentAsync(initialComment, comment); return(RedirectToPage("../Posts/Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Comment comment = new Comment(); comment.Id = CommentDTO.CommentId; comment.Text = CommentDTO.Text; comment.PostPostId = CommentDTO.PostPostId; try { var result = await pcc.UpdateCommentAsync(comment); } catch (Exception) { return(RedirectToAction("Error")); } return(RedirectToPage("./List")); }