public PaginatedList <UserItemView> Search(UserSearchFilter filter, PaginationInfoView paginationInfo) { var query = _repository.Query <User>() .Where(x => x.Status == Core.UserStatus.Active); if (!string.IsNullOrWhiteSpace(filter.UserName)) { query = query.Where(x => x.UserName == filter.UserName); } if (!string.IsNullOrWhiteSpace(filter.FirstName)) { query = query.Where(x => x.FirstName == filter.FirstName); } if (!string.IsNullOrWhiteSpace(filter.LastName)) { query = query.Where(x => x.LastName == filter.LastName); } if (filter.Status != Core.UserStatus.None) { query = query.Where(x => x.Status == filter.Status); } var newQuery = query.Select( x => new UserItemView { FirstName = x.FirstName, LastName = x.LastName, UserName = x.UserName, Status = x.Status, Id = x.Id }); return(new PaginatedList <UserItemView>(paginationInfo, newQuery)); }
public PaginatedList <ProductView> Search(ProductSearchFilter filter, PaginationInfoView paginationInfo) { var query = _repository.Query <EntityModel.Product>(); if (filter.Id > 0) { query = query.Where(x => x.Id == filter.Id); } if (!String.IsNullOrEmpty(filter.Name)) { query = query.Where(x => x.Name.Contains(filter.Name)); } query = query.Where(x => x.Status == Status.Active); var newQuery = query.Select(x => new ProductView { Id = x.Id, Name = x.Name, Status = x.Status, Price = x.Price, RefId = x.RefId, Image = x.Image, Description = x.Description, Type = x.Type }); PaginatedList <ProductView> paginatedList = new PaginatedList <ProductView>(paginationInfo, newQuery); return(paginatedList); }
public PaginatedListDict(PaginationInfoView paginationInfo, IQueryable <T> query) { TotalRecordCount = query.Count(); var pageSize = paginationInfo.PageSize; TotalPageCount = (int)Math.Ceiling((float)TotalRecordCount / pageSize); paginationInfo.PageIndex = paginationInfo.PageIndex <1 ? 1 : paginationInfo.PageIndex = paginationInfo.PageIndex> TotalPageCount ? 1 : paginationInfo.PageIndex; CurrentPageIndex = paginationInfo.PageIndex; var skipCount = (CurrentPageIndex - 1) * paginationInfo.PageSize; query = query.Skip(skipCount) .Take(paginationInfo.PageSize); //var newQuery = query.Select( // x => new RoleItemView // { // }); var list = query.ToList(); }
public PaginatedListNew(PaginationInfoView paginationInfo, List <List <T> > list) { TotalRecordCount = list.Count(); var pageSize = paginationInfo.PageSize; TotalPageCount = (int)Math.Ceiling((float)TotalRecordCount / pageSize); paginationInfo.PageIndex = paginationInfo.PageIndex <1 ? 1 : paginationInfo.PageIndex = paginationInfo.PageIndex> TotalPageCount ? 1 : paginationInfo.PageIndex; CurrentPageIndex = paginationInfo.PageIndex; }
public PaginatedList <OrderView> Search(OrderSearchFilter filter, PaginationInfoView paginationInfo) { var query = _repository.Query <Order>(); if (filter.Id > 0) { query = query.Where(x => x.Id == filter.Id); } if (filter.CompanyId > 0) { query = query.Where(x => x.CompanyId == filter.CompanyId); } if (filter.ProductId > 0) { query = query.Where(x => x.ProductId == filter.ProductId); } if (filter.OrderStatus >= 0) { query = query.Where(x => x.OrderStatus == filter.OrderStatus); } query = query.Where(x => x.Status == Status.Active); var newQuery = query.Select(x => new OrderView { Id = x.Id, RefId = x.RefId, CompanyId = x.CompanyId, ProductId = x.ProductId, Status = x.Status, Description = x.Description, Discount = x.Discount, Total = x.Total, SetPaid = x.SetPaid, PaymentMethod = x.PaymentMethod, Currency = x.Currency }); PaginatedList <OrderView> paginatedList = new PaginatedList <OrderView>(paginationInfo, newQuery); return(paginatedList); }
public PaginatedList(IEnumerable <T> source, PaginationInfoView paginationInfo) { if (source == null) { throw new ArgumentNullException("source"); } if (paginationInfo == null) { throw new ArgumentNullException("paginationInfo"); } PageIndex = paginationInfo.PageIndex; PageSize = paginationInfo.PageSize; TotalCount = source.Count(); TotalPageCount = (int)Math.Ceiling(TotalCount / (double)PageSize); if (PageIndex > TotalPageCount || PageIndex < 1) { PageIndex = 1; } List = source.Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList(); }
public PaginatedListN(PaginationInfoView paginationInfo, List <T> list) { TotalRecordCount = list.Count; var pageSize = paginationInfo.PageSize; TotalPageCount = (int)Math.Ceiling((float)TotalRecordCount / pageSize); paginationInfo.PageIndex = paginationInfo.PageIndex <1 ? 1 : paginationInfo.PageIndex = paginationInfo.PageIndex> TotalPageCount ? 1 : paginationInfo.PageIndex; CurrentPageIndex = paginationInfo.PageIndex; var skipCount = (CurrentPageIndex - 1) * paginationInfo.PageSize; list = list.Skip(skipCount) .Take(paginationInfo.PageSize).ToList(); List = list; }
public PaginatedList <RoleItemView> Search(RoleSearchFilter filter, PaginationInfoView paginationInfo) { var query = _repository.Query <Role>(); if (!string.IsNullOrWhiteSpace(filter.Name)) { query = query.Where(x => x.Name == filter.Name); } if (!string.IsNullOrWhiteSpace(filter.Code)) { query = query.Where(x => x.Code == filter.Code); } var newQuery = query.Select( x => new RoleItemView { Name = x.Name, Code = x.Code, Id = x.Id }); return(new PaginatedList <RoleItemView>(paginationInfo, newQuery)); }
//public static IPaginatedList<T> AsPagination<T>(this IEnumerable<T> source, int pageIndex) //{ // return new PaginatedList<T>(source, pageIndex); //} //public static IPaginatedList<T> AsPagination<T>(this IEnumerable<T> source, int pageIndex, int pageSize) //{ // return new PaginatedList<T>(source, pageIndex, pageSize); //} public static PaginatedList <T> AsPagination <T>(this IEnumerable <T> source, PaginationInfoView paginationInfo) { return(new PaginatedList <T>(source, paginationInfo)); }