29.05.2015 Views

o_19mgorv9t13a3ko71fev19l81mqa.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A view model is not part of the domain model. It is just a convenient class for passing data between the controller and the view.<br />

To emphasize this, I put this class in the SportsStore.WebUI project to keep it separate from the domain model classes.<br />

Adding the HTML Helper Method<br />

Now that I have a view model, I can implement the HTML helper method, which I am going to call PageLinks. Create a new<br />

folder in the SportsStore.WebUI project called HtmlHelpers and add a new class file called<br />

PagingHelpers.cs, the contents of which Listing 7-18 shows.<br />

Listing 7-18. The Contents of the PagingHelpers.cs Class File<br />

using System;<br />

using System.Text;<br />

using System.Web.Mvc;<br />

using SportsStore.WebUI.Models;<br />

namespace SportsStore.WebUI.HtmlHelpers {<br />

public static class PagingHelpers {<br />

public static MvcHtmlString PageLinks(this HtmlHelper html,<br />

PagingInfo pagingInfo,<br />

Func pageUrl) {<br />

}<br />

}<br />

}<br />

StringBuilder result = new StringBuilder();<br />

for (int i = 1; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!