コード例 #1
0
ファイル: ListPostViewModel.cs プロジェクト: silne30/TPCv3
 public ListPostViewModel(IBlogRepository blogRepository, int pageNo)
 {
     _blogRepository = blogRepository;
     Posts = _blogRepository.Posts(pageNo - 1, itemsPerPage);
     TotalPosts = _blogRepository.TotalPosts();
     PagingInfo = new PagingInfo
                      {CurrentPage = pageNo, ItemsPerPage = itemsPerPage, TotalItems = TotalPosts};
 }
コード例 #2
0
 public ProjectsListViewModel(IProjectRepository projectRepository, int pageNo, int itemsPerPage)
 {
     _projectRepository = projectRepository;
     Projects = _projectRepository.Projects(pageNo - 1, itemsPerPage);
     TotalProjects = _projectRepository.TotalProjects();
     PagingInfo = new PagingInfo
                      {
                          CurrentPage = pageNo,
                          ItemsPerPage = itemsPerPage,
                          TotalItems = TotalProjects
                      };
 }
コード例 #3
0
ファイル: ListPostViewModel.cs プロジェクト: silne30/TPCv3
 public ListPostViewModel(IBlogRepository blogRepository, string text, string type, int pageNo)
 {
     _blogRepository = blogRepository;
     switch (type)
     {
         case "Category":
             {
                 Posts = _blogRepository.PostsForCategory(text, pageNo - 1, itemsPerPage);
                 TotalPosts = _blogRepository.TotalPostsForCategory(text);
                 Category = _blogRepository.Category(text);
                 PagingInfo = new PagingInfo
                                  {
                                      CurrentPage = pageNo,
                                      ItemsPerPage = itemsPerPage,
                                      TotalItems = TotalPosts,
                                      CurrentCategory = text
                                  };
                 break;
             }
         case "Tag":
             {
                 Posts = _blogRepository.PostsForTags(text, pageNo - 1, itemsPerPage);
                 TotalPosts = _blogRepository.TotalPostsForTag(text);
                 Tag = _blogRepository.Tag(text);
                 CurrentTag = Tag.Name;
                 PagingInfo = new PagingInfo
                                  {
                                      CurrentPage = pageNo,
                                      ItemsPerPage = itemsPerPage,
                                      TotalItems = TotalPosts,
                                      CurrentTag = text
                                  };
                 break;
             }
         default:
             {
                 Posts = _blogRepository.PostsForSearch(text, pageNo - 1, itemsPerPage);
                 TotalPosts = _blogRepository.TotalPostsForSearch(text);
                 CurrentSearchString = text;
                 PagingInfo = new PagingInfo
                                  {
                                      CurrentPage = pageNo,
                                      ItemsPerPage = itemsPerPage,
                                      TotalItems = TotalPosts,
                                      CurrentSearchString = text
                                  };
                 break;
             }
     }
 }
コード例 #4
0
 public ProjectsListViewModel(IProjectRepository projectRepository, string category, int pageNo, int itemsPerPage)
 {
     _projectRepository = projectRepository;
     Projects = _projectRepository.ProjectsForCategory(category, pageNo - 1, itemsPerPage);
     TotalProjects = _projectRepository.TotalProjectsForCategory(category);
     CurrentCategory = category;
     PagingInfo = new PagingInfo
                      {
                          CurrentPage = pageNo,
                          ItemsPerPage = itemsPerPage,
                          TotalItems = TotalProjects,
                          CurrentCategory = category
                      };
 }
コード例 #5
0
ファイル: PagingHelpers.cs プロジェクト: silne30/TPCv3
 public static MvcHtmlString PageLinks(this HtmlHelper html, PagingInfo pagingInfo, Func<int, string> pageUrl)
 {
     var result = new StringBuilder();
     for (var i = 1; i <= pagingInfo.TotalPages; i++){
         var tag = new TagBuilder("a");
         tag.MergeAttribute("href", pageUrl(i));
         tag.InnerHtml = Convert.ToString(i);
         if (i == pagingInfo.CurrentPage){
             tag.AddCssClass("selected_paginator");
         }
         result.Append(tag);
     }
     return MvcHtmlString.Create(result.ToString());
 }