This is part of the series “Blog with ASP.NET Core and React/Redux”.
Goal for this part
Before we start implementing features like stories search, likes or comments we want to have some data in our DB. So the goal for this part is to write a script that will populate our database with mock data.
This part will have only back-end part. We will write a script that will fetch users stories from Medium and save them in our format.
Let’s start by creating a new project.
$ dotnet new console -o Blog.Mocker
Now, we want to specify what we mean by mock data. It will be just a list of users and a list of stories. With time we can extend our pack, but for now, this set of data is sufficient.
In this part, we will use Medium to get mock data, but maybe someday we will want to use some other source. So we will make an interface for our mock data generator.
The simplest method for getting user stories from Medium appears to be fetching RSS feed. We will not take info about the user from this feed but only take some fields from the stories he made.
In order to use RSS helpers, we need to install an additional library.
$ dotnet add package Microsoft.SyndicationFeed.ReaderWriter
Our Program file will consist of this steps.
- Get mock set of data by passing list of usernames to Medium instance method.
- Specify BlogContext.
- Saving users to DB.
- Saving stories to DB.
In the next part, we will allow a user to like stories. Stay tuned!
Reach the next level of focus and productivity with increaser.org.