Outline

Exercise: Complete the Articles Controller Imlementation

In the Conduit.Api Project complete the implementation of the follow methods in the ArticlesController.cs file.

Get Article Feed

Modify the GetArticlesFeed method by adding an await call to the GetArticlesFeedAsync method in the IArticlesRepository Interface Class.

Return an Ok Response with a new object containing:

  • Article array
  • Article Count

Fix the errors:

  • Make the method async
  • Have Visual Studio generate the missing method for you

Hint: Review GetArticlesAsync Method in the ArticlesController

Get Article by Slug

Modify the GetArticlesBySlug method by adding an await call to the GetArticlebySlugAsync method in the IArticlesRepository Interface Class.

Return an Ok Response with a new object containing:

  • A single Article

Fix the errors:

  • Make the method async
  • Have Visual Studio generate the missing method for you

Add an additional Catch Block to handle ArticleNotFoundException:

  • Log as a warning
  • Return a 422 Response

Hint: Review AddCommentsToArticleAsync Method in the ArticlesController

Update Article

Modify the UpdateArticle method by adding an await call to the UpdateArticleAsync method in the IArticlesRepository Interface Class.

Return an Ok Response with a new object containing:

  • The new Article

Fix the errors:

  • Make the method async
  • Have Visual Studio generate the missing method for you

Delete Article

Modify the DeleteArticle method by adding an await call to the DeleteArticleAsync method in the IArticlesRepository Interface Class.

Return a NoContent() Response:

  • No Parameters are needed

Fix the errors:

  • Make the method async
  • Have Visual Studio generate the missing method for you

Get Comments from Article

Modify the GetCommentsFromArticle method by adding an await call to the GetCommentsFromArticleAsync method in the IArticlesRepository Interface Class.

Return an Ok Response with a new object containing:

  • A Comment array

Fix the errors:

  • Make the method async
  • Have Visual Studio generate the missing method for you

Delete Comment for Article

Modify the DeleteCommentsForArticle method by adding an await call to the DeleteCommentsForArticleAsync method in the IArticlesRepository Interface Class.

Return a NoContent() Response:

  • No Parameters are needed

Fix the errors:

  • Make the method async
  • Have Visual Studio generate the missing method for you

Favorite Article

Modify the FavoriteArticle method by adding an await call to the FavoriteArticleAsync method in the IArticlesRepository Interface Class.

Return an Ok Response with a new object containing:

  • A single Article

Fix the errors:

  • Make the method async
  • Have Visual Studio generate the missing method for you

Unfavorite Article

Modify the UnfavoriteArticle method by adding an await call to the UnfavoriteArticleAsync method in the IArticlesRepository Interface Class.

Return an Ok Response with a new object containing:

  • A single Article

Fix the errors:

  • Make the method async
  • Have Visual Studio generate the missing method for you
 

I finished! On to the next chapter