The Blog Buildout: Day 5

Jerry McKeeJerry McKee
2 min read

On Day 5, two more features were added to the blog: a search function and Pagination. We'll start with the Pagination

Pagination is the ability to take the long page of blog posts and make the view more manageable by breaking the total count of blogs and breaking it down into a specified number of posts displayed in each grouping, or page. For this blog I have it set to 4 posts per page. In order to be achieved in the blog I used two new NuGet packages, x.PagedList and x.PagedList.Mvc.Core. These two libraries provide the code necessary to set up the ability to add paging to the Blog. This was not to difficult to add the need code to both the Controller and to the View. Once the necessary code was added, styling was applied to the paging controls but it is still something I'm working on to style with the rest of the blog.

The search function was a little more challenging to work with. This function brought me back to the service layer where I built out a service method that returned a list blogs that contained a search string that a a blog consumer types into the search box. The reason for build this method in the service follows the reasoning with why most of the blog's main functionality is set up in the service layer; it is because I want to isolate the calls to the database from a secure area of the code. This decision comes because there could be some vulnerabilities between the view and Controller. Having logic to look through the database separated as far from those vulnerabilities becomes a layer of security to protect data in the database.

The rest of the day was set in styling work done to the blog which will continue on over the weekend. So far the blog is on track to go live the day before Thanksgiving .

Thank you to those who followed along this week. This is my first time creating a blog series and so I'm learning how to create more appealing posts. If you have any suggestions, please leave them in the comments and I will see you all on Monday.

Happy Friday && Happy Coding!!

0
Subscribe to my newsletter

Read articles from Jerry McKee directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Jerry McKee
Jerry McKee