private IQueryable <Quote> QueryQuotes(Filters.QuoteFilterOptions options, PagingSettings paging = null)
        {
            var quotes = Context.Quote.Where(q => !q.Deleted.HasValue);

            if (options != null)
            {
                if (options.Order == "desc")
                {
                    quotes = quotes.OrderByDescending(x => x.CreatedDate);
                }
            }


            if (paging != null)
            {
                quotes = quotes.Distinct().OrderByDescending(l => l.CreatedDate).ToPagedQueryable(paging);
            }

            return(quotes);
        }
Beispiel #2
0
        public PaginatedListTests()
        {
            //create InMemory DbContext
            DbContextOptions <TestDbContext> options;
            var builder = new DbContextOptionsBuilder <TestDbContext>();

            builder.UseInMemoryDatabase("PaginatedListTests")
            .EnableSensitiveDataLogging();
            options  = builder.Options;
            _context = new TestDbContext(options);
            _context.Database.EnsureDeleted();
            _context.Database.EnsureCreated();

            var settings = new PagingSettings
            {
                PageSize = 20
            };

            _settings = Microsoft.Extensions.Options.Options.Create(settings);


            _items = new List <TestModel>();
            for (int i = 0; i < _testItemsCount; i++)
            {
                _items.Add(new TestModel()
                {
                    Id = Guid.NewGuid(), Name = "test" + i
                });
            }

            for (int i = 0; i < _testItemsCount; i++)
            {
                _items.Add(new TestModel()
                {
                    Id = Guid.NewGuid(), Name = "name" + i
                });
            }

            _context.AddRange(_items);
            _context.SaveChanges();
        }
Beispiel #3
0
 /// <summary>
 /// Get collection's documents
 /// </summary>
 /// <param name="settings">Istance of PagingSettings</param>
 /// <param name="sortings">list of sortingField</param>
 /// <param name="token">cancellation token async support</param>
 /// <returns>Return list of documents</returns>
 public virtual async Task <IEnumerable <T> > Get(PagingSettings settings, IEnumerable <SortingField> sortings, CancellationToken token = default(CancellationToken)) => (IEnumerable <T>) await GetCollection(null, settings, sortings, null, token);
Beispiel #4
0
 /// <summary>
 /// Get collection's documents
 /// </summary>
 /// <param name="filter">lambda expression filter</param>
 /// <param name="settings">Istance of PagingSettings</param>
 /// <param name="sortings">list of sortingField</param>
 /// <param name="token">cancellation token async support</param>
 /// <returns>Return list of documents</returns>
 public virtual async Task <IEnumerable <T> > Get(Expression <Func <T, bool> > filter, PagingSettings settings, IEnumerable <SortingField> sortings, CancellationToken token = default(CancellationToken)) => (IEnumerable <T>) await GetCollection(filter, settings, sortings, null, token);
Beispiel #5
0
 public static List <T> ToPagedList <T>(this List <T> items, PagingSettings paging)
 {
     return(items.Skip((paging.PageIndex - 1) * paging.PageCount).Take(paging.PageCount).ToList());
 }
Beispiel #6
0
 public static IQueryable <T> ToPagedQueryable <T>(this IQueryable <T> items, PagingSettings paging)
 {
     return(items.Skip((paging.PageIndex - 1) * paging.PageCount).Take(paging.PageCount));
 }
        public List <Webhook> GetWebhookList()
        {
            var settings = new PagingSettings();

            return(GetWebhookListPager(settings));
        }
Beispiel #8
0
 public List <Lead> GetAll(Filters.LeadFilterOptions options = null, PagingSettings paging = null)
 {
     return(Repository.GetAll(options, paging));
 }
 /// <summary>
 /// Get collection's documents
 /// </summary>
 /// <param name="settings">Istance of PagingSettings</param>
 /// <param name="projection">defines a projection document to specify or restrict fields to return</param>
 /// <param name="token">cancellation token async support</param>
 /// <returns>Return list of documents</returns>
 public virtual async Task <IEnumerable <T> > Get(PagingSettings settings, Expression <Func <T, object> > projection, CancellationToken token = default(CancellationToken))
 {
     return((IEnumerable <T>) await GetCollection(null, settings, null, projection, token));
 }
 /// <summary>
 /// Get collection's documents
 /// </summary>
 /// <param name="settings">Istance of PagingSettings</param>
 /// <param name="token">cancellation token async support</param>
 /// <returns>Return list of documents</returns>
 public virtual async Task <IEnumerable <T> > Get(PagingSettings settings, CancellationToken token = default(CancellationToken))
 {
     return((IEnumerable <T>) await GetCollection(null, settings, null, null, token));
 }
 /// <summary>
 /// Get collection's documents
 /// </summary>
 /// <param name="filter">lambda expression filter</param>
 /// <param name="settings">Istance of PagingSettings</param>
 /// <param name="sortings">list of sortingField</param>
 /// <param name="projection">defines a projection document to specify or restrict fields to return</param>
 /// <param name="token">cancellation token async support</param>
 /// <returns>Return list of documents</returns>
 public virtual async Task <IEnumerable <T> > Get(Expression <Func <T, bool> > filter, PagingSettings settings, IEnumerable <SortingField> sortings, Expression <Func <T, object> > projection, CancellationToken token = default(CancellationToken))
 {
     return((IEnumerable <T>) await GetCollection(filter, settings, sortings, projection, token));
 }
        public List <Page> GetPageList(long surveyId)
        {
            var settings = new PagingSettings();

            return(GetPageListPager(surveyId, settings));
        }
 public List <Question> GetQuestionList(long surveyId, long pageId, PagingSettings settings)
 {
     return(GetQuestionListPager(surveyId, pageId, settings));
 }
        public List <Question> GetQuestionList(long surveyId, long pageId)
        {
            var settings = new PagingSettings();

            return(GetQuestionListPager(surveyId, pageId, settings));
        }
 public List <Page> GetPageList(long surveyId, PagingSettings settings)
 {
     return(GetPageListPager(surveyId, settings));
 }
Beispiel #16
0
 public List <QuoteItem> GetAllItems(Filters.QuoteItemFilterOptions options = null, PagingSettings paging = null)
 {
     return(Repository.GetAllItems(options, paging));
 }
Beispiel #17
0
        public List <Task> GetAll(Filters.TaskFilterOptions options = null, PagingSettings paging = null)
        {
            var tasks = QueryTasks(options, paging);

            return(tasks.ToList());
        }
        public List <Message> GetMessageList(long collectorId)
        {
            var settings = new PagingSettings();

            return(GetMessageListPager(collectorId, settings));
        }
Beispiel #19
0
        public async Task <IActionResult> OnGetAsync(int id, int?pageIndex)
        {
            string token = await idData.GetAccessToken(HttpContext);

            Token = token;

            try
            {
                Data = new CategoriesViewModel {
                    Data = await client.Get(token, id)
                };
                if (Data.Data.UserId != idData.GetClaimId(User))
                {
                    Onwer = await usersClient.Get(token, Data.Data.UserId);
                }

                Paging = new PagingSettings
                {
                    ItemCountPerPage = 8,
                    RouteData        = new Dictionary <string, string>
                    {
                        ["id"] = Data.Data.Id.ToString(),
                    }
                };
                IEnumerable <Note> notes;
                {
                    int count = (await nodesClient.Query(token, categoryId: Data.Data.Id, targets: NoteTargets.Count)).Count();
                    Paging.MaximumIndex = (count / Paging.ItemCountPerPage) + (count % Paging.ItemCountPerPage > 0 ? 1 : 0);
                    if (!pageIndex.HasValue)
                    {
                        pageIndex = 1;
                    }
                    Paging.CurrentIndex = pageIndex.Value;
                    int offset = (Paging.CurrentIndex - 1) * Paging.ItemCountPerPage;

                    notes = await nodesClient.Query(token, categoryId : Data.Data.Id, offset : offset, count : Paging.ItemCountPerPage);

                    Notes = notes.ToList();
                }

                /*{
                 *  Dictionary<int, Relation> rs = new Dictionary<int, Relation>();
                 *  foreach (Note v in notes)
                 *  {
                 *      foreach (Relation r in await relationsClient.GetAdjacents(token, v.Id))
                 *      {
                 *          if (rs.ContainsKey(r.Id))
                 *          {
                 *              continue;
                 *          }
                 *
                 *          rs.Add(r.Id, r);
                 *      }
                 *  }
                 *  Graph = new GraphViewModel
                 *  {
                 *      Graph = await RelationHelper.GenerateGraph(nodesClient, client, rs.Values, token)
                 *  };
                 * }*/
            }
            catch
            {
                return(NotFound());
            }

            return(Page());
        }
 public List <Message> GetMessageList(long collectorId, PagingSettings settings)
 {
     return(GetMessageListPager(collectorId, settings));
 }
 public List <Webhook> GetWebhookList(PagingSettings settings)
 {
     return(GetWebhookListPager(settings));
 }
        public List <Recipient> GetRecipientList(long collectorId, long messageId)
        {
            var settings = new PagingSettings();

            return(GetRecipientListPager(collectorId, messageId, settings));
        }
Beispiel #23
0
 public static List <T> ToPagedList <T>(this IQueryable <T> items, PagingSettings paging)
 {
     return(ToPagedQueryable(items, paging).ToList());
 }
 public List <Recipient> GetRecipientList(long collectorId, long messageId, PagingSettings settings)
 {
     return(GetRecipientListPager(collectorId, messageId, settings));
 }
        public void ShouldReturnPagedSearchResult([Substitute] SearchService service, ISearchServiceRepository serviceRepository, ISearchSettingsRepository settingsRepository, QueryRepository queryRepository, string query, ISearchResults searchResults, [Substitute] SearchController searchController, IRenderingPropertiesRepository renderingPropertiesRepository, [Substitute] PagingSettings pagingSettings)
        {
            renderingPropertiesRepository.Get <PagingSettings>().Returns(pagingSettings);
            service.Search(Arg.Any <IQuery>()).Returns(searchResults);
            serviceRepository.Get().Returns(service);
            var controller = new SearchController(serviceRepository, settingsRepository, queryRepository, renderingPropertiesRepository);
            var result     = controller.PagedSearchResults(query, null) as ViewResult;

            result.Model.Should().BeOfType <PagedSearchResults>();
        }
        public List <Invoice> GetAll(Filters.InvoiceFilterOptions options = null, PagingSettings paging = null)
        {
            var invoices = QueryInvoices(options, paging);

            return(invoices.ToList());
        }
Beispiel #27
0
 /// <summary>
 /// Get collection's documents
 /// </summary>
 /// <param name="filter">lambda expression filter</param>
 /// <param name="settings">Istance of PagingSettings</param>
 /// <param name="projection">defines a projection document to specify or restrict fields to return</param>
 /// <param name="token">cancellation token async support</param>
 /// <returns>Return list of documents</returns>
 public virtual async Task <IEnumerable <T> > Get(Expression <Func <T, bool> > filter, PagingSettings settings, Expression <Func <T, object> > projection, CancellationToken token = default(CancellationToken)) => (IEnumerable <T>) await GetCollection(filter, settings, null, projection, token);
        private IQueryable <Invoice> QueryInvoices(Filters.InvoiceFilterOptions options, PagingSettings paging = null)
        {
            var invoices = Context.Invoice.Where(i => !i.Deleted.HasValue);

            if (options != null)
            {
                if (options.Order == "desc")
                {
                    invoices = invoices.OrderByDescending(x => x.CreatedDate);
                }
            }

            if (paging != null)
            {
                invoices = invoices.Distinct().OrderByDescending(l => l.CreatedDate).ToPagedQueryable(paging);
            }
            return(invoices);
        }
Beispiel #29
0
 /// <summary>
 /// Get collection's documents
 /// </summary>
 /// <param name="settings">Istance of PagingSettings</param>
 /// <param name="sortings">list of sortingField</param>
 /// <param name="projection">defines a projection document to specify or restrict fields to return</param>
 /// <param name="token">cancellation token async support</param>
 /// <returns>Return list of documents</returns>
 public virtual async Task <IEnumerable <T> > Get(PagingSettings settings, IEnumerable <SortingField> sortings, Expression <Func <T, object> > projection, CancellationToken token = default(CancellationToken)) => (IEnumerable <T>) await GetCollection(null, settings, sortings, projection, token);
 public List <InvoiceItem> GetAllItems(InvoiceItemFilterOptions options = null, PagingSettings paging = null)
 {
     return(Context.InvoiceItem.Where(q => !q.Deleted.HasValue).ToList());
 }