/// <summary> /// /// </summary> /// <param name="limit"></param> /// <param name="offset"></param> /// <param name="imgType">为空或为-1表示查询全部图片,否则查询指定类别的</param> /// <returns></returns> public JsonResult GetImagesList(int limit, int offset, string imgType = null) { var page = new Page { PageNumber = offset / limit + 1, PageSize = limit }; IPagedList <Image> res = null; if (string.IsNullOrEmpty(imgType) || imgType == "-1") { res = imageApplication.FindByPageDesc(page); } else { ImageType imageType; if (Enum.TryParse <ImageType>(imgType, out imageType)) { //转换成功,查询类别 res = imageApplication.FindToList(page, imageType); } else { res = imageApplication.FindToList(page);//转换失败,查询全部 } } return(Json(new { //hasNextPage = res.HasNextPage, //hasPreviousPage = res.HasPreviousPage, total = res.TotalItemCount, datas = res.Select(m => new { id = m.ImageId, name = m.IName, img = m.IFileName, data = m.IFileName }) }, JsonRequestBehavior.AllowGet)); }
public async Task <CarDtoWithTotals> GetCars(int page = 1, int take = 10) { IPagedList <Car> cars = _carsRepo.GetAll(page, take); var carsDto = cars.Select(car => new CarDto { Brand = new ListItemDto { Id = car.Brand.Id, Name = car.Brand.Name }, ChassisType = new ListItemDto { Id = car.ChassisType.Id, Name = car.ChassisType.Name }, Id = car.Id, Created = car.Created, ModelName = car.ModelName, SeatsCount = car.SeatsCount, Url = car.Url }).ToList(); return(new CarDtoWithTotals { Total = cars.TotalItemCount, Cars = carsDto }); }
public async Task List_ReturnViewResult() { // Arrange var logService = Substitute.For <ILogService>(); var usernames = _logs.Select(t => t.Username).OrderBy(t => t).Distinct().ToList(); logService.GetLogs(Arg.Any <LogPagedDataRequest>()).Returns(_logs); logService.GetUsernames().Returns(usernames); var sut = new LogsController(logService); // Act var result = await sut.List() as ViewResult; // Assert Assert.IsNotNull(result); Assert.AreEqual("List", result.ViewName); var model = (LogSearchModel)result.Model; Assert.AreEqual(4, model.AvailableUsernames.Count); Assert.AreEqual("All", model.AvailableUsernames[0].Text); Assert.AreEqual("", model.AvailableUsernames[0].Value); Assert.AreEqual("Not Available", model.AvailableUsernames[1].Text); Assert.AreEqual("NOT AVAILABLE", model.AvailableUsernames[1].Value); Assert.AreEqual(usernames[0], model.AvailableUsernames[2].Text); Assert.AreEqual(usernames[0], model.AvailableUsernames[2].Value); Assert.AreEqual(usernames[1], model.AvailableUsernames[3].Text); Assert.AreEqual(usernames[1], model.AvailableUsernames[3].Value); }
public ActionResult Index(int?page, string sortOrder, bool descending = true, bool reversable = false) { AppUser user = GetCurrentUser(); if (reversable) { ReverseSorting(ref descending, sortOrder); } IEnumerable <Order> model = user.Orders; IEnumerable <OrderViewModel> mappedModel = _mapper.Map <IEnumerable <OrderViewModel> >(model); IEnumerable <OrderViewModel> sortedModel = mappedModel.SortBy(x => x.Created, sortOrder, descending); int pageNumber = page ?? 1; IPagedList <OrderViewModel> viewModel = sortedModel.ToPagedList(pageNumber, 5); viewModel = viewModel.Select(x => { x.Created = x.Created.ToLocalTime(); return(x); }); SaveSortingState(sortOrder, descending); if (Request.IsAjaxRequest()) { return(PartialView(viewModel)); } return(View(viewModel)); }
private object GetDataSource(IPagedList <Education_GroupLearner_Agent> listPaged) { object dataSource = listPaged.Select(o => new MyColumnCollectionDGAgent(o.Education_Agent) { Agent_Matricule = o.Education_Agent.Agent_Matricule, Agent_FirstName = o.Education_Agent.Agent_FirstName, Agent_Fullname = o.Education_Agent.Agent_FullName, Agent_Name = o.Education_Agent.Agent_Name, Function_Name = o.Education_Agent.Agent_Function == null ? null : o.Education_Agent.Education_Function.Function_Name, //Function_Name = o.Agent_Function == null ? null : dbEntities.Education_Function.Where(x => x.Function_Id == o.Agent_Function).FirstOrDefault().Function_Name,// If (o.Function == null) { null } else {o.Function.Function_Name} Agent_Admin = o.Education_Agent.Agent_Admin, //Agent_Responsable = o.Agent_LineManager == null ? null : dbEntities.Education_Agent.Where(x => x.Agent_Id == o.Agent_LineManager).FirstOrDefault().Agent_FullName, Agent_InRoute = o.Education_Agent.Education_InRoute == null ? "" : o.Education_Agent.Education_InRoute.InRoute_Name, Agent_IsWorksManager = o.Education_Agent.Agent_IsWorksManager, Agent_DateSeniority = o.Education_Agent.Agent_DateSeniority, Agent_DateOfEntry = o.Education_Agent.Agent_DateOfEntry, Agent_DateFunction = o.Education_Agent.Agent_DateFunction, Habilitation_Name = o.Education_Agent.Education_Habilitation == null ? null : o.Education_Agent.Education_Habilitation.Habilitation_Name, AgentStatus_Name = o.Education_Agent.Education_AgentStatus == null ? null : o.Education_Agent.Education_AgentStatus.AgentStatus_Name, Agent_Etat = o.Education_Agent.Agent_Etat }).ToList(); return(dataSource); }
public static AccountMyAuctionsViewModel FromAuctions(IPagedList<Auction> auctions, string titleFilter, int createdInDays, AuctionStatusFilter currentStatusFilter) { Contract.Requires(auctions != null); var items = auctions.Select(x => new AccountMyAuctionsViewModel.Item { Id = x.Id, Title = x.Title, CategoryName = x.Category.Name, CategoryId = x.Category.Id, Status = x.Status, TimeTillEnd = x.EndDate - DateTime.Now, BuyoutPrice = x.BuyoutPrice, BestOffer = x.BestOffer != null ? x.BestOffer.Money : null }); return new AccountMyAuctionsViewModel { Auctions = new StaticPagedList<AccountMyAuctionsViewModel.Item>(items, auctions), TitleFilter = titleFilter, CreatedIn = TimeSpan.FromDays(createdInDays), CurrentStatusFilter = currentStatusFilter }; }
private static async Task <IEnumerable <string> > GetInProgressBuildsAsync(IBuildHttpClient client, int pipelineId, Guid projectId) { IPagedList <WebApi.Build> builds = await client.GetBuildsAsync( projectId, definitions : new int[] { pipelineId }, statusFilter : WebApi.BuildStatus.InProgress); return(builds.Select(build => build.GetWebLink())); }
/// <summary> /// /// </summary> /// <param name="Period"></param> /// <param name="LoggerProviderName"></param> /// <param name="LogLevel"></param> /// <returns></returns> public FeedResult RssFeed(string Period, string LoggerProviderName, string LogLevel) { string defaultPeriod = Session["Period"] == null ? "This Week" : Session["Period"].ToString(); string defaultLoggerProviderName = Session["LoggerProviderName"] == null ? "All" : Session["LoggerProviderName"].ToString(); string defaultLogLevel = Session["LogLevel"] == null ? "Error" : Session["LogLevel"].ToString(); Period = (Period == null) ? defaultPeriod : Period; LoggerProviderName = (LoggerProviderName == null) ? defaultLoggerProviderName : LoggerProviderName; LogLevel = (LogLevel == null) ? defaultLogLevel : LogLevel; TimePeriod timePeriod = TimePeriodHelper.GetUtcTimePeriod(Period); // Grab ALL entries for the feed (DO NOT PAGE feed DATA!!!) IPagedList <LogEvent> chartEntries = loggingRepository.GetByDateRangeAndType(0, Int32.MaxValue, timePeriod.Start, timePeriod.End, LoggerProviderName, LogLevel); var postItems = chartEntries.Select(p => new SyndicationItem(string.Format("{0} - {1} - {2}", p.LogDate, p.Level, p.LoggerProviderName), p.Message, new Uri(Url.AbsoluteAction("Details", new { LoggerProviderName = p.LoggerProviderName, Id = p.Id })))); Uri feedAlternateLink = Url.ActionFull("Index", "Logging"); var feed = new SyndicationFeed("MVC Logging Demo -> Log Reporting", string.Format("Log Provider: {0}, Log Level : {1}, From {2} to {3} ({4})", LoggerProviderName, LogLevel, timePeriod.Start.ToShortDateString(), timePeriod.End.ToShortDateString(), Period), feedAlternateLink, postItems) { Language = "en-US" }; return(new FeedResult(new Rss20FeedFormatter(feed))); }
public async Task List_ReturnViewResult() { // Arrange var traceLogService = Substitute.For <ITraceLogService>(); var usernames = _traceLogs.Select(t => t.PerformedBy).OrderBy(t => t).Distinct().ToList(); traceLogService.GetTraceLogs(Arg.Any <TraceLogPagedDataRequest>()).Returns(_traceLogs); traceLogService.GetPerformedUsernames().Returns(usernames); var sut = new TraceLogsController(traceLogService); // Act var result = await sut.List() as ViewResult; // Assert Assert.IsNotNull(result); Assert.AreEqual("List", result.ViewName); var model = (TraceLogSearchModel)result.Model; Assert.AreEqual(3, model.AvailableUsernames.Count); Assert.AreEqual("All", model.AvailableUsernames[0].Text); Assert.AreEqual("", model.AvailableUsernames[0].Value); Assert.AreEqual(usernames[0], model.AvailableUsernames[1].Text); Assert.AreEqual(usernames[0], model.AvailableUsernames[1].Value); Assert.AreEqual(usernames[1], model.AvailableUsernames[2].Text); Assert.AreEqual(usernames[1], model.AvailableUsernames[2].Value); }
public static P.PagedList <C> ConvertPagedList <T, C>(this IPagedList <T> pagedList) { var collectionPagedList = pagedList.Select(x => x); var mappedCollection = AutoMapperConfiguration.Mapper.Map <IEnumerable <C> >(collectionPagedList); return(new P.PagedList <C>(mappedCollection, pagedList.PageIndex, pagedList.PageSize, pagedList.TotalCount)); }
public IActionResult List(ProductPictureModifierSearchModel searchModel) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) { return(AccessDeniedView()); } ProductAttribute productAttribute = _productPictureModifierService. GetProductAttributeByName(ProductPictureModifierDefault.ProductAttributeName).First(); IPagedList <Product> products = _productService. GetProductsByProductAtributeId(productAttribute.Id, searchModel.Page - 1, searchModel.PageSize); var model = new ProductPictureModifierListModel() { Data = products.Select(product => new ProductPictureModifierModel { EntityId = product.ProductAttributeMappings .First(x => x.ProductAttributeId == productAttribute.Id).Id, ProductName = product.Name, ProductId = product.Id, ColorCode = product.ProductAttributeMappings .First(x => x.ProductAttributeId == productAttribute.Id).DefaultValue }), Total = products.TotalCount }; return(Json(model)); }
/// <summary> /// Map a paged list of models to a viewmodel equivalent /// </summary> /// <typeparam name="T">Model item type</typeparam> /// <typeparam name="TReturn">Viewmodel item type</typeparam> /// <param name="baseList"></param> /// <param name="itemMapper">Function to map a model item to it's viewmodel</param> /// <returns>Paged list containing viewmodels</returns> public static IPagedList <TReturn> MapToViewModel <T, TReturn>(this IPagedList <T> baseList, Func <T, TReturn> itemMapper) { var mappedItems = baseList.Select(itemMapper); var newList = new StaticPagedList <TReturn>(mappedItems, baseList.GetMetaData()); return(newList); }
public virtual IActionResult ProductAddPopupList(AddProductToCategorySearchModel searchModel) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) { return(AccessDeniedView()); } ProductAttribute productAttribute = _productPictureModifierService. GetProductAttributeByName(ProductPictureModifierDefault.ProductAttributeName).First(); IPagedList <Product> products = _productPictureModifierService.SearchProducts( searchModel.SearchProductName, searchModel.SearchCategoryId, productAttribute.Id, searchModel.Page - 1, searchModel.PageSize); var model = new DataSourceResult { Data = products.Select(product => product.ToModel <ProductModel>()), Total = products.TotalCount }; return(Json(model)); }
public CareRequestsListModel PrepareCareRequestsListModel(IPagedList <CareRequest> requests) { return(new CareRequestsListModel { Requests = requests.Select(PrepareCareRequestModel).ToList(), Pager = Extensions.Extensions.ToSimplePagerModel(requests) }); }
public IPagedList <TDestination> Convert(IPagedList <TSource> source, IPagedList <TDestination> destination, ResolutionContext context) { var vm = source.Select(m => context.Mapper.Map <TSource, TDestination>(m)).ToList(); return(new StaticPagedList <TDestination>(vm, source.GetMetaData())); }
public WorkerListViewModel PrepareWorkersListViewModel(IPagedList <Worker> workers) { return(new WorkerListViewModel { Workers = workers.Select(PrepareWorkerItemModel).ToList(), Pager = Extensions.Extensions.ToSimplePagerModel(workers) }); }
public PeopleListViewModel PreparePeopleListViewModel(IPagedList <Customer> customers) { return(new PeopleListViewModel { People = customers.Select(PrepareCustomerModel).ToList(), Pager = Extensions.Extensions.ToSimplePagerModel(customers) }); }
public PersonRequestListModel PreparePersonRequestsListModel(IPagedList <PersonRequest> requests) { return(new PersonRequestListModel { Items = requests.Select(PreparePersonRequestItemModel).ToList(), Pager = Extensions.Extensions.ToSimplePagerModel(requests) }); }
public static IPagedList <T> FetchList <T, TE>(IPagedList <TE> list) where T : ModelBase, new() where TE : class, new() { var result = list.Select(item => ObjectUtil.Fetch(new T(), item)).ToList(); return(new PagedList <T>(result, list.PageNumber, list.PageSize, list.TotalItemCount)); }
public OfferListModel PrepareProductListModel(IPagedList <Offer> offers) { return(new OfferListModel() { Offers = offers.Select(PrepareOfferItemModel).ToList(), Pager = Extensions.Extensions.ToSimplePagerModel(offers) }); }
public ProductListModel PrepareProductListModel(IPagedList <Product> products) { return(new ProductListModel { Products = products.Select(PrepareProductItemModel).ToList(), Pager = Extensions.Extensions.ToSimplePagerModel(products) }); }
public virtual CommentsListModel PrepareCommentsListModel(IPagedList <TblPostComments> comments, int postId, bool isAdmin) { return(new CommentsListModel() { CommentsList = comments.Select(p => PrepareCommentBodyModel(p, isAdmin)), PostId = postId }); }
public RoleListResponse Execute(RoleListRequest request) { RoleListResponse roleListResponse = new RoleListResponse(); IPagedList <RoleInfo> pagedRoles = ServiceHelper.LoadService <IRoleService>().GetPagedRoles(request.PageNumber, request.PageSize); List <RoleModel> list = pagedRoles.Select <RoleInfo, RoleModel>((Func <RoleInfo, RoleModel>)(m => m.ToModel())).ToList <RoleModel>(); roleListResponse.Roles = new PagedData <RoleModel>((IEnumerable <RoleModel>)list, (IPagedList)pagedRoles); return(roleListResponse); }
public PagedTypedList(IPagedList <TSource> source, Func <TSource, TDestination> func) { TotalCount = source.TotalCount; PageCount = source.PageCount; Page = source.Page; PageSize = source.PageSize; AddRange(source.Select(func)); }
public PersonGridModel(IPagedList <Person> source) { GetDefaultColumns(); this.Pager = new GridPager { PageIndex = source.PageIndex, PageSize = source.PageSize, TotalPages = source.TotalPages, TotalRecords = source.TotalCount }; this.Rows = source.Select(x => x).ToList(); this.Pager.CurrentPage = source.PageIndex < source.TotalPages ? source.PageIndex + 1 : source.TotalPages; }
private object GetDataSource(IPagedList <Education_Formation> listPaged) { object dataSource = listPaged.Select(o => new MyColumnCollectionFrmFormation(o) { Formation_ShortTitle = o.Formation_ShortTitle, Formation_SAP = o.Formation_SAP, }).ToList(); return(dataSource); }
/// <summary> /// IPagedList列表结果 entity 转 model - 分页结果Result /// </summary> /// <typeparam name="TEntity">领域实体 类型</typeparam> /// <typeparam name="TModel">业务实体 类型</typeparam> /// <param name="source">源列表</param> /// <param name="convertFunc">entity 转 model 委托</param> /// <returns>PagerResultOfBoolean</returns> public static PagerResultOfBoolean <TModel> ToPagerResultOfBool <TEntity, TModel>(this IPagedList <TEntity> source, Func <TEntity, TModel> convertFunc) where TEntity : class, new() { List <TModel> list = source.Select(convertFunc).ToList(); return(new PagerResultOfBoolean <TModel> { List = list, Pager = source.Pager }); }
public static DatasourceResult <TDestination> ToModel <TSource, TDestination>(this IPagedList <TSource> data) { return(new DatasourceResult <TDestination>() { Data = data.Select(x => x.MapTo <TSource, TDestination>()).ToList(), Pager = new Pager(data.PageIndex, data.PageSize) { TotalRecords = data.TotalRecords } }); }
public RegistryItemsPage(IPagedList<Gift> gifts, IEnumerable<Category> categories, int pageSize,int selectedCategory) { Gifts =gifts.Select((gift, i) => new GiftRow {Item = gift, IsFirst = i == 0}); Categories = categories.ToList(); TotalNumberOfItems = gifts.TotalItemCount; PageNumber = gifts.PageNumber; PageCount = gifts.PageCount; FirstItemIndex = gifts.FirstItemIndex; LastItemIndex = gifts.LastItemIndex; PageSize = pageSize; SelectedCategoryId = selectedCategory; }
private void btnRefresh_Click(object sender, EventArgs e) { if (!this.DesignMode) { list = GetPagedListAsync(); btnPrevious.Enabled = list.HasPreviousPage; btnNext.Enabled = list.HasNextPage; dgElectronicFiles.DataSource = list.Select(o => new { Name = o.FileName, Type = o.FileType.Name, Format = o.Path.Substring(o.Path.LastIndexOf('.') + 1) }).ToList(); lblPageCount.Text = string.Format("Page {0}/{1}", pageNumber, list.PageCount); } }
public IHttpActionResult GetHome([FromUri] StoryFilterRequest storyFilterRequest) { IPagedList <Story> pagedStories = storyService.GetLastestStories(storyFilterRequest.Language, storyFilterRequest.GetPagination()); if (pagedStories == null) { return(NotFound()); } return(Ok(new PagedListResponse <StoryResponse>(pagedStories, pagedStories.Select(c => new StoryResponse(c, this))))); }
public IHttpActionResult Get([FromUri] StoryTextRequest storyTextRequest) { IPagedList <Story> pagedStories = storyService.GetStoriesWithText(storyTextRequest.Text, storyTextRequest.Language, storyTextRequest.GetPagination(), storyTextRequest.GetOrdering()); if (pagedStories == null) { return(NotFound()); } return(Ok(new PagedListResponse <StoryResponse>(pagedStories, pagedStories.Select(c => new StoryResponse(c, this))))); }
public static CategoryIndexViewModel FromAuctions(IPagedList<Auction> auctions, AuctionSortOrder currentSortOrder, int? categoryId = null) { Contract.Requires(auctions != null); return new CategoryIndexViewModel { CategoryId = categoryId, Auctions = new StaticPagedList<AuctionViewModel>(auctions.Select(AuctionViewModelMapper.FromAuction), auctions), CurrentSortOrder = currentSortOrder, }; }
public static UsersIndexViewModel FromUsers(IPagedList<User> users, UserSortOrder currentSortOrder) { Contract.Requires(users != null); var items = users.Select(x => new UsersIndexViewModel.Item { Id = x.Id, UserName = x.UserName, RealName = x.FullName, IsBanned = x.IsBanned, BanExpiryTime = x.LockoutEndDateUtc.HasValue ? x.LockoutEndDateUtc.Value.ToLocalTime() : (DateTime?)null }); return new UsersIndexViewModel { Users = new StaticPagedList<UsersIndexViewModel.Item>(items, users), CurrentSortOrder = currentSortOrder }; }
private IEnumerable<SaleProductModel> Convert(IPagedList<productDto> sources) { if (sources == null) return null; return sources.Select(t => { var data = new SaleProductModel() { brandname = t.brand.name, categoryname = t.category.name, gendername = t.gender.name, unitprice = t.unitprice, code = t.code, name = t.name, imgpath = t.imagemain, productid = t.key }; data.details.AddRange(t.v_stocks.Select(o => new SaleProductDetailModel() { productid = t.key, size = o.size.code, displaysize = o.size.displaycode, sizeid = o.sizeid, stockquantity = o.stockquantity })); return data; }); }
private IPagedList<ComplaintViewModel> GetPagedComplaintList(IPagedList<Complaint> complaints) { var complaintViewModels = complaints.Select(c => _complaintBuilder.BuildViewModel(c)).ToList(); return new PagedList<ComplaintViewModel>(complaintViewModels, complaints.PageIndex, complaints.PageSize, complaints.TotalItemCount); }