public IActionResult OnPostDeleteComment(Guid commentId, string id) { Post post = _dataStore.GetPost(id); Comment foundComment = _dataStore.FindComment(commentId, post); foundComment.IsPublic = false; _dataStore.SavePost(post); return(Redirect($"/Post/{id}/{post.Slug}")); }
public void FindComment_SwitchIsPublicValue() { BlogDataStore testDataStore = new BlogDataStore(new FakeFileSystem()); Post testPost = new Post { Slug = "Test-slug", Title = "Test title", Body = "Test body", PubDate = DateTime.Now, LastModified = DateTime.Now, IsPublic = true, Excerpt = "Test excerpt" }; var comment1 = new Comment { AuthorName = "Test name", AuthorEmail = "Test email", Body = "test body", PubDate = DateTime.Now, IsPublic = true }; var comment2 = new Comment { AuthorName = "Test name", AuthorEmail = "Test email", Body = "test body", PubDate = DateTime.Now, IsPublic = true }; testPost.Comments.Add(comment1); testPost.Comments.Add(comment2); testDataStore.SavePost(testPost); Comment newcom = testDataStore.FindComment(comment1.UniqueId, testPost); Assert.Equal(testPost.Comments.Count, 2); Assert.Equal(newcom.UniqueId, comment1.UniqueId); }