public async Task Should_Delete_Post() { // Arrange var post = new Domain.Post { Content = "Content", Title = "Title", Comments = new [] { new Domain.Comment { CommentText = "CommentText" } } }; _posts.Add(post); // Act await _postProvider.DeletePost(post.PostId); // Assert Assert.IsEmpty(_posts); }
public ActionResult DeletePost(int postId) { try { _postProvider.DeletePost(postId); return(Redirect("~/Post/PostsList")); } catch (SqlException ex) { _logger.LogError(ex.Message); ViewBag.Message = ex.Message; return(View("SqlError")); } catch (Exception ex) { _logger.LogError(ex.Message); return(Redirect("/Error/ServerError")); } }
public async Task DeletePost(int postId) { await _postProvider.DeletePost(postId); }
public bool DeletePost(Post post) { return(_postProvider.DeletePost(post)); }