Skip to content

Instantly share code, notes, and snippets.

@pielegacy
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pielegacy/84b4bc4948fb67573b5a to your computer and use it in GitHub Desktop.
Save pielegacy/84b4bc4948fb67573b5a to your computer and use it in GitHub Desktop.
For Talfies <3
<div class="quotes-container">
@{
var items = Model.ToList(); //Getting Database Model and converting it to a list for easy operations
int maxpage = items.Count / 26; //Finding the max page (int floors the decimal place which helps)
int startpoint = items.Count() - 1;
if (page > 1)
{
startpoint -= 26 * (page - 1);
}
for (var i = startpoint; i >= items.Count() - 26 * page && i > 0; i--) //Basic For Loop printing the quotes to screen
{
<div class="quote-element">
<a class="enter-quote" href="/Quotes/Details/@items[i].QuoteId"><i><h2>"@Html.DisplayFor(modelItem => items[i].QuoteText)"</h2></i></a>
<p>- @Html.DisplayFor(modelItem => items[i].QuoteAuthor) , <a href="/Quotes/Topics/@items[i].TopicId">Part of @Html.DisplayFor(modelItem => items[i].Topic.TopicName)</a></p>
</div>
}
}
</div>
<div class="text-center">
<strong>Page</strong><br />
@{
if (page > 1)
{
@Html.ActionLink("<", "Index", new { p = page - 1 }, new { @class = "paginate" });
}
<strong class ="paginate">@page</strong>
if (page <= maxpage) {
@Html.ActionLink(">", "Index", new { p = page + 1 }, new { @class = "paginate" });
}
}
<br />
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment