Outline

Demo: Delete Comment from Article

Just like in the video where I list the comment for an Article, I'll follow the chain of methods to the Repository where I want to implement the code.

We'll have the Context pull the Commentary from the database but this time we'll indicate that we want to match the Id along with the Slug. This will ensure we're getting the correct record.

As always make sure that you fix the method signature by making it async.

We'll need to verify that the Commentary belongs to the Logged In User because only they are allowed to delete their own comments.

If it everything checks out we'll have the Context Remove the Commentary and Save the Changes.

Another easy score where you can start doing the end zone dance as if you scored a touch down. Let's go for the extra point and see if it actually works.

You'll need to login as the person who will be deleting the comment.

Let's check to see what Articles are available that we can choose from. You can choose any Article you feel is appropriate. I'll choose mine.

We'll get the list of comments for the Slug we chose.

I have my Comment Id. I hope you have yours. Now, let's go delete it.

Plug in your Slug and the Id. Execute and watch it get deleted. This gives us a 204 No Content Message. It's equivalent to a 200 Success.

Let's verify by listing the comments for the slug that it really gone. Depending on how many comments you have you should show one less.

In the next video, we'll be implementing Favorite & Unfavorite Article. I'll see you there.

 

I finished! On to the next chapter