Articles Part 2

Articles Feed


Demo: Get Articles Feed

Let's continue working down the line for each method in the Articles Controller. The next one is Get Articles Feed. Let's Right-Click and Go To definition.

The first thing we need to do is get the account for the logged in user. We should never get a null but let's go ahead and perform a null check on the account. If the account is null (meaning there is no logged in user) set the accountId variable to zero (0).

From this point forward we proceed with familiar code we've written in the past.

We grab the Editorials from the Context, Where the Logged In User is Following Authors, we include the Favorites, the People (in this case the Person) and any Tags for each Article. We sort the records in Descending order according to the CreadtedAt column, Skip based on the offset Parameter, Take according to the limit parameter and create a Generic List from the result.

We'll use our handy-dandy ArticleListMapper to create a Generic List of Articles and finally return the Array of Articles back to the Controller.

We should give this a quick test run to make sure it's working correctly…

We need to login first to get the Feed for the Logged In User. In case I'll type in my email and my super-secret password. Once I successfully login I can grab my JSON Web Token to authenticate. Up at the very top we click on the authorize where we type in "Bearer ". Click on Authorize and Close.

Now we can check out our Feed.

We get the 200 Success response. We still don't have any articles but we're getting close. We're almost to the point where we can begin to create articles.

I'll see you in the next video.


I finished! On to the next chapter