public bool DeletePost(int postId) { bool isDeleted = false; try { using (NightCapDBContext nightCapDBContext = new NightCapDBContext()) { Post post = nightCapDBContext.Posts.Find(postId); nightCapDBContext.Remove(post); nightCapDBContext.SaveChanges(); isDeleted = true; } } catch (SqlException) { throw; } return(isDeleted); }
public bool DeleteComment(int commentId) { bool isDeleted = false; try { using (NightCapDBContext nightCapDBContext = new NightCapDBContext()) { Comment comment = nightCapDBContext.Comments.Find(commentId); nightCapDBContext.Remove(comment); nightCapDBContext.SaveChanges(); isDeleted = true; } } catch (SqlException) { throw; } return(isDeleted); }