Recent posts support to the blogging system

The recent posts feature could be added to the system by performing the following steps:

  1. Create an IGetRecentPostQuery query object interface.
  2. Create a GetRecentPostQuery concrete query object.
  3. Create a RecentPostsViewComponent View component.
  4. Create a Default.cshtml view under Shared | Components | RecentPosts.
  5. Perform a component invoke using the View component name and its parameter.

To reduce more code footprint where we just add features to the blogging system, let's maintain and share the code from Git repository commits. The previously listed implementation is performed and available in the following Git repository commit:

https://goo.gl/kcWD3P

We will be using View components to render the recent posts. It is a new concept that replaces the child actions in ASP.NET MVC Core, and it would be out of scope to explain them in detail, so kindly refer to the following official documentation for more information:

https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-components

The following screenshot will render the Recent Posts as a view component:

We have seen the changes required to include recent posts to the system. In the next section, let's focus on how anonymous posts were listed and an individual anonymous post was displayed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset