当前位置: 首页>>代码示例>>C#>>正文


C# StaticPagedList类代码示例

本文整理汇总了C#中StaticPagedList的典型用法代码示例。如果您正苦于以下问题:C# StaticPagedList类的具体用法?C# StaticPagedList怎么用?C# StaticPagedList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StaticPagedList类属于命名空间,在下文中一共展示了StaticPagedList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRangeAsync

        public async Task<IEnumerable<IQuestion>> GetRangeAsync(Guid fieldId, GenericFilter filter)
        {
            try
            {
                if (filter != null)
                {
                    //Get all questions from a field with matching id
                    //var questions = AutoMapper.Mapper.Map<IEnumerable<IQuestion>>(await Repository.GetAsync<QuestionEntity>(q => q.Field.Id.Equals(fieldId)));
                    var questions = AutoMapper.Mapper.Map<IEnumerable<IQuestion>>(await Repository.GetWhere<QuestionEntity>().Where(q => q.FieldId.Equals(fieldId)).ToListAsync());

                    if (!string.IsNullOrWhiteSpace(filter.SearchString))
                    {
                        questions = questions.Where(q => q.Title.ToLower().Contains(filter.SearchString.ToLower())).ToList();
                    }

                    var page = questions.ToPagedList(filter.PageNumber, filter.PageSize);
                    var questionPagedList = new StaticPagedList<IQuestion>(page, page.GetMetaData());
                    return questionPagedList;
                }
                else
                {
                    //If filter is null, return all questions from field
                    return AutoMapper.Mapper.Map<IEnumerable<IQuestion>>(await Repository.GetAsync<QuestionEntity>(q => q.Field.Id.Equals(fieldId))).ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:LukaLoina,项目名称:StartUp-Mentor,代码行数:30,代码来源:QuestionRepository.cs

示例2: GetAllAsync

        /// <summary>
        /// Get all lost person from red cross
        /// </summary>
        /// <param name="redCrossId"></param>
        /// <returns></returns>
        public async Task<IEnumerable<ILostPerson>> GetAllAsync(Guid redCrossId, GenericFilter filter)
        {
            try
            {
                if (filter != null)
                {
                    var lp = AutoMapper.Mapper.Map<IEnumerable<ILostPerson>>(await Repository.GetEverything<LostPersonEntity>()).OrderBy(l => l.LastName).ToList();

                    if (redCrossId != null)
                    {
                        lp = lp.Where(l => l.RedCrossId.Equals(redCrossId)).ToList();
                    }

                    var page = lp.ToPagedList(filter.pageNumber, filter.pageSize);
                    var lpPage = new StaticPagedList<ILostPerson>(page, page.GetMetaData());
                    return lpPage;
                }
                else
                {
                    return AutoMapper.Mapper.Map<IEnumerable<ILostPerson>>(await Repository.GetAllAsync<LostPersonEntity>(l => l.RedCrossId.Equals(redCrossId))).OrderBy(l => l.ReportDate).ToList();
                }

                //return AutoMapper.Mapper.Map<IEnumerable<ILostPerson>>(await Repository.GetAllAsync<LostPersonEntity>(l => l.RedCrossEntityId.Equals(redCrossId))).OrderBy(l => l.LastName); //Destination ILostPerson; Source: LostPersonEntity
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:Nodios,项目名称:RepacMono,代码行数:34,代码来源:LostRepository.cs

示例3: GetAsync

        /// <summary>
        /// Get all
        /// </summary>
        /// <returns></returns>
        public async Task<IEnumerable<IRedCross>> GetAsync(GenericFilter filter)
        {
            
            try
            {
                if (filter != null)
                {
                    var rc = AutoMapper.Mapper.Map<IEnumerable<IRedCross>>(await Repository.GetEverything<RedCrossEntity>()).OrderBy(r => r.Name).ToList();

                    if (!string.IsNullOrWhiteSpace(filter.searchString))
                    {
                        rc = rc.Where(r =>
                            r.Name.ToLower().Contains(filter.searchString.ToLower()) ||
                            r.Country.ToLower().Contains(filter.searchString.ToLower())
                        ).ToList();
                    }

                    var page = rc.ToPagedList(filter.pageNumber, filter.pageSize);
                    var rcPage = new StaticPagedList<IRedCross>(page, page.GetMetaData());
                    return rcPage;
                }
                else
                {
                    return AutoMapper.Mapper.Map<IEnumerable<IRedCross>>(await Repository.GetEverything<RedCrossEntity>()).OrderBy(r => r.Name).ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:Nodios,项目名称:RepacMono,代码行数:35,代码来源:RedRepository.cs

示例4: Index

 public ActionResult Index(int page = 1,int State=3)
 {
     List<Demand> demands = new List<Demand>();
     List<vDemand> vdemands = new List<vDemand>();
     string whereStr = "";
     if(State==0||State==1||State==2)
     {
         whereStr = "State="+ State;
     }
     var query = bllSession.IDemandBLL.GetList(whereStr);
     int state_num_1 = bllSession.IDemandBLL.GetList("State=0").Count();
     int state_num_2 = bllSession.IDemandBLL.GetList("State=1").Count();
     int state_num_3 = bllSession.IDemandBLL.GetList("State=2").Count();
     int totalCount = 0;
     PagerHelper.DoPage(ref query, page, 20, ref totalCount);
     foreach (var item in query)
     {
         vdemands.Add(new vDemand(item));
     }
     ViewBag.StateNum = state_num_1 + state_num_2 + state_num_3;
     ViewBag.StateNum1 = state_num_1;
     ViewBag.StateNum2 = state_num_2;
     ViewBag.StateNum3 = state_num_3;
     var demandAsIPagedList = new StaticPagedList<vDemand>(vdemands, page, 20, totalCount);
     return View(demandAsIPagedList);
 }
开发者ID:applenele,项目名称:SmallCode,代码行数:26,代码来源:DemandController.cs

示例5: Index

        // GET: Blog
        public ActionResult Index(int page = 1, string Category = "", string Date = "")
        {
            bool result = false;
            string attachUrl = "";
            List<vArticle> articles = new List<vArticle>();
            string whereStr = "";
            if (!string.IsNullOrEmpty(Category))
            {
                attachUrl = "Category = " + Category;
                whereStr = whereStr + "Category = '" + Category + "'";
            }
            if (!string.IsNullOrEmpty(Date))
            {
                attachUrl = "Date = " + Date;
                whereStr = whereStr + " DATE_FORMAT(a.Time,'%Y-%m') = '" + Date + "'";
            }
            var query = bllSession.IArticleBLL.GetList(whereStr);
            int totalCount = 0;
            PagerHelper.DoPage(ref query, page, 5, ref totalCount);
            foreach (var item in query.ToTextFilter(out result))
            {
                articles.Add(new vArticle(item));
            }
            var articleAsIPagedList = new StaticPagedList<vArticle>(articles, page, 5, totalCount);//.ToTextFilter(out result);

            object Categories = CacheHelper.GetCacheValue("ArticleCategories");
            object Calendars = CacheHelper.GetCacheValue("ArticleCalendars");

            ViewBag.Categories = Categories;
            ViewBag.Calendars = Calendars;
            ViewBag.AttachUrl = attachUrl;
            return View(articleAsIPagedList);
        }
开发者ID:applenele,项目名称:SmallCode,代码行数:34,代码来源:BlogController.cs

示例6: GetMaskedCredentialList

		public PagedSortedList<DeployCredentialsMasked> GetMaskedCredentialList(ListOptions listOptions)
		{
			var list = _credentialsRepository.GetCredentialsList(listOptions);
			var mappedList = list.Items.Select(i=>AutoMapper.Mapper.Map(i, new DeployCredentialsMasked())).ToList();
			var pagedList = new StaticPagedList<DeployCredentialsMasked>(mappedList, list.PageNumber, list.PageSize, list.TotalItemCount);
			return new PagedSortedList<DeployCredentialsMasked>(pagedList, list.SortField, list.SortAscending);
		}
开发者ID:gsbastian,项目名称:Sriracha.Deploy,代码行数:7,代码来源:CredentialsManager.cs

示例7: GetDeployBatchStatusList

		public PagedSortedList<DeployBatchStatus> GetDeployBatchStatusList(ListOptions listOptions)
		{
            var requestList = _deployRepository.GetBatchRequestList(listOptions);
            var returnListItems = requestList.Items.Select(i => BuildDeployBatchStatus(i)).ToList();
            var pagedList = new StaticPagedList<DeployBatchStatus>(returnListItems, requestList.PageNumber, requestList.PageSize, requestList.TotalItemCount);
            return new PagedSortedList<DeployBatchStatus>(pagedList, listOptions.SortField, listOptions.SortAscending.Value);
		}
开发者ID:gsbastian,项目名称:Sriracha.Deploy,代码行数:7,代码来源:DeployRequestManager.cs

示例8: GetAsync

        public async Task<IEnumerable<IAnswer>> GetAsync(GenericFilter filter)
        {
            try
            {
                if (filter != null)
                {
                    var answers = AutoMapper.Mapper.Map<IEnumerable<IAnswer>>(await Repository.GetRangeAsync<AnswerEntity>()).ToList();

                    if (!string.IsNullOrWhiteSpace(filter.SearchString))
                    {
                        answers = answers.Where(a => a.Date.ToShortDateString().Contains(filter.SearchString)).ToList();
                    }

                    var page = answers.ToPagedList(filter.PageNumber, filter.PageSize);
                    var answerPagedList = new StaticPagedList<IAnswer>(page, page.GetMetaData());
                    return answerPagedList;
                }
                else
                {
                    return AutoMapper.Mapper.Map<IEnumerable<IAnswer>>(await Repository.GetRangeAsync<AnswerEntity>()).ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:LukaLoina,项目名称:StartUp-Mentor,代码行数:27,代码来源:AnswerRepository.cs

示例9: Index

        public ActionResult Index(string sortOrder, string currentFilter, string search, int page = 1)
        {
            ViewBag.CurrentSort = sortOrder;
            ViewBag.IDSortParm = "id_asc";
            ViewBag.DescripcionSortParm = String.IsNullOrEmpty(sortOrder) ? "descripcion_asc" : "";
            ViewBag.CantSensoresSortParm = String.IsNullOrEmpty(sortOrder) ? "cantsensores_asc" : "";

            if (Session["user"] == null)
                return RedirectToAction("Login", "Account");

            if (search != null)
                page = 1;
            else
                search = currentFilter;

            ViewBag.CurrentFilter = search;

            // Setup base query - not evaluated
            IQueryable<EquipoTipo> equipos = servicio.ObtenerTodos();

            if (!String.IsNullOrEmpty(search))
            {
                equipos = equipos.Where(s => s.descripcion.Contains(search));
            }

            switch (sortOrder)
            {
                case "id_asc":
                    equipos = equipos.OrderBy(s => s.idEquipoTipo);
                    break;
                case "descripcion_asc":
                    equipos = equipos.OrderBy(s => s.descripcion);
                    break;
                case "cantsensores_asc":
                    equipos = equipos.OrderBy(s => s.cantSensores);
                    break;
                default:
                    equipos = equipos.OrderBy(s => s.idEquipoTipo);
                    break;
            }

            var pageSize = 20;

            // Count of all matching records (hits database, but count is relatively quick)
            var equiposCount = equipos.Count();
            // List of current page of 20 records (hits database again, pulls only 20 records, though)
            var equiposList = equipos.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            // Map just the 20 records to view models
            var viewModelEquipoTipos = Mapper.Map<IEnumerable<EquipoTipo>, IEnumerable<EquipoTipoViewModel>>(equiposList);

            // Create StaticPagedList instance to page with
            var model = new StaticPagedList<EquipoTipoViewModel>(viewModelEquipoTipos, page, pageSize, equiposCount);

            return View(model); 
        }
开发者ID:GSystemsLucasMaspero,项目名称:LojackPruebasEnCapas,代码行数:56,代码来源:EquipoTipoController.cs

示例10: UserController_Index_ShouldReturnTheResultOfServiceCallAsViewData

        public void UserController_Index_ShouldReturnTheResultOfServiceCallAsViewData()
        {
            var users = new StaticPagedList<User>(new List<User>(), 1, 1, 0);
            var userSearchQuery = new UserSearchQuery();
            A.CallTo(() => _userSearchService.GetUsersPaged(userSearchQuery)).Returns(users);

            ActionResult actionResult = _userController.Index(userSearchQuery);

            _userController.ViewData["users"].Should().Be(users);
        }
开发者ID:neozhu,项目名称:MrCMS,代码行数:10,代码来源:UserControllerTests.cs

示例11: Index

        public ActionResult Index(int? page)
        {
            int pageIndex = (page ?? 1) - 1;
            int pagesize=10;
            var result = _F41010Manager.GetData(pageIndex, pagesize);
            var ItemAsIPagedList = new StaticPagedList<F41010Model>(result, pageIndex+1, pagesize, int.Parse(_F41010Manager.GetDataCount().ToString()));

            ViewBag.onePageList = ItemAsIPagedList;

            return View(result);
        }
开发者ID:ppsett,项目名称:PNK-Restful-service,代码行数:11,代码来源:ItemMasterController.cs

示例12: FindByEmail

        public IPagedList<MembershipUser> FindByEmail(string emailAddressToMatch, int pageNumber, int pageSize)
		{
			// get one page of users
			int totalUserCount;
            var usersCollection = _membershipProvider.FindUsersByEmail(emailAddressToMatch, pageNumber - 1, pageSize, out totalUserCount);

			// convert from MembershipUserColletion to PagedList<MembershipUser> and return
			var converter = new EnumerableToEnumerableTConverter<MembershipUserCollection, MembershipUser>();
			var usersList = converter.ConvertTo<IEnumerable<MembershipUser>>(usersCollection);
            var usersPagedList = new StaticPagedList<MembershipUser>(usersList, pageNumber, pageSize, totalUserCount);
			return usersPagedList;
		}
开发者ID:dperlyuk,项目名称:MembershipStarterKit,代码行数:12,代码来源:AspNetMembershipProviderWrapper.cs

示例13: ArtistIndex

        public ArtistIndex(PartialFindResult<ArtistWithAdditionalNamesContract> result, string filter,
            ArtistType artistType, bool? draftsOnly, ArtistSortRule sort, int? page, IndexRouteParams routeParams)
        {
            Artists = new StaticPagedList<ArtistWithAdditionalNamesContract>(result.Items, page ?? 1, 30, result.TotalCount);
            DraftsOnly = draftsOnly ?? false;
            Filter = filter;
            ArtistType = artistType;
            Sort = sort;
            RouteParams = routeParams;

            FilterableArtistTypes = EnumVal<ArtistType>.Values.ToDictionary(a => a, Translate.ArtistTypeName);
        }
开发者ID:realzhaorong,项目名称:vocadb,代码行数:12,代码来源:Index.cs

示例14: FindAll

        public IPagedList<MembershipUser> FindAll(int pageIndex, int pageSize)
        {
            // get one page of users
            int totalUserCount;
            var usersCollection = _membershipProvider.GetAllUsers(pageIndex, pageSize, out totalUserCount);

            // convert from MembershipUserColletion to PagedList<MembershipUser> and return
            var converter = new EnumerableToEnumerableTConverter<MembershipUserCollection, MembershipUser>();
            var usersList = converter.ConvertTo<IEnumerable<MembershipUser>>(usersCollection);
            var usersPagedList = new StaticPagedList<MembershipUser>(usersList, pageIndex, pageSize, totalUserCount);
            return usersPagedList;
        }
开发者ID:softlion,项目名称:MembershipStarterKit,代码行数:12,代码来源:AspNetMembershipProviderWrapper.cs

示例15: StaticPagedList_uses_supplied_totalItemCount_to_determine_subsets_position_within_superset

		public void StaticPagedList_uses_supplied_totalItemCount_to_determine_subsets_position_within_superset(int pageNumber, bool shouldBeFirstPage, bool shouldBeLastPage)
		{
			//arrange
			var subset = new[] {1, 1, 1};

			//act
			var list = new StaticPagedList<int>(subset, pageNumber, 3, 9);

			//assert
			Assert.Equal(pageNumber, list.PageNumber);
			Assert.Equal(shouldBeFirstPage, list.IsFirstPage);
			Assert.Equal(shouldBeLastPage, list.IsLastPage);
		}
开发者ID:kpi-ua,项目名称:X.PagedList,代码行数:13,代码来源:StaticPagedListFacts.cs


注:本文中的StaticPagedList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。