Exemplo n.º 1
0
        public static MvcHtmlString LinkHelper(this HtmlHelper helper, LedgerListModel listModel, Func<int, string> links)
        {
            StringBuilder builder = new StringBuilder();

            for (int i = 1; i <= listModel.NumberOfLinks; i++)
            {
                TagBuilder tagBuilder = new TagBuilder("a");
                tagBuilder.MergeAttribute("href", links(i));
                tagBuilder.InnerHtml = "" + i;

                builder.Append(tagBuilder.ToString());
                builder.Append("  ");
            }

            return MvcHtmlString.Create(builder.ToString());
        }
Exemplo n.º 2
0
        // page - indicates which results page to display
        public ViewResult List(int page = 1)
        {
            IQueryable<LedgerEntry> list = Entries.GetEntries;

            int skipCount = (page - 1) * EntriesPerPage;            // Number of entries to skip depending on current page
            int leftOver = list.Count() - skipCount;                // Number of remaining entries
            NumberOfLinks = list.Count() / EntriesPerPage + (list.Count() % EntriesPerPage == 0 ? 0 : 1);

            LedgerListModel ListModel = new LedgerListModel
            {
                NumberOfEntries = (leftOver > EntriesPerPage ? EntriesPerPage : leftOver),
                EntriesPerPage = this.EntriesPerPage,
                NumberOfLinks = this.NumberOfLinks
            };

            ViewData["listmodel"] = list
                .OrderByDescending(e => e.Time)
                .Skip( skipCount )
                .Take(EntriesPerPage);

            return View(ListModel);
        }