public ActionResult Entries(int page = 1) { var pageIndex = page - 1; var result = Service.GetActivityEntries(PagingProperties.CreateFromPage(pageIndex, entriesPerPage, false)); return(PartialView("ActivityEntryContracts", result.Items)); }
public AlbumQueryParams() { AlbumType = DiscType.Unknown; ArtistParticipationStatus = ArtistAlbumParticipationStatus.Everything; Common = new CommonSearchParams(); Paging = new PagingProperties(0, 30, true); }
private PartialFindResult <Album> FindAdvanced( ISession session, string query, PagingProperties paging, AlbumSortRule sortRule) { var queryPlan = new AlbumQueryBuilder().BuildPlan(query); return(FindAdvanced(session, queryPlan, paging, sortRule)); }
private PartialFindResult <Album> FindAdvanced( ISession session, QueryPlan <Album> queryPlan, PagingProperties paging, AlbumSortRule sortRule) { if (!queryPlan.Any()) { return(new PartialFindResult <Album>(new Album[] {}, 0)); } IQueryable <Album> albums = null; foreach (var filter in queryPlan) { if (albums == null) { albums = filter.Query(session); } else { albums = filter.Filter(albums, session); } } var result = albums .Skip(paging.Start) .Take(paging.MaxEntries) .ToArray(); return(new PartialFindResult <Album>(result, albums.Count())); }
public void Constructor_FieldList() { //Arrange List <SortField <TestPost> > fields = new List <SortField <TestPost> >() { }; fields.Add(new SortField <TestPost>() { Field = p => p.Category, IsAscending = true }); fields.Add(new SortField <TestPost>() { Field = p => p.Id, IsAscending = true }); //Act _pagingProperties = new PagingProperties <TestPost>(fields); //Assert Assert.AreEqual(2, _pagingProperties.SortFields.Count); Assert.AreEqual(_pagingProperties.DefaultPageSize, _defaultPageSize); Assert.AreEqual(0, _pagingProperties.TotalPages); Assert.AreEqual(0, _pagingProperties.TotalPages); Assert.AreEqual(0, _pagingProperties.TotalResults); }
public SongQueryParams() { Common = new CommonSearchParams(); IgnoredIds = new int[] {}; Paging = new PagingProperties(0, 30, true); SongTypes = new SongType[] {}; }
private PartialFindResult <Album> FindAdvanced( ISession session, QueryPlan <Album> queryPlan, PagingProperties paging, AlbumSortRule sortRule) { var querySource = new QuerySourceSession(session); var processor = new QueryProcessor <Album>(querySource); return(processor.Query(queryPlan, paging, q => AlbumSearchSort.AddOrder(q, sortRule, LanguagePreference))); }
public SongQueryParams() { ArtistParticipationStatus = ArtistAlbumParticipationStatus.Everything; Common = new CommonSearchParams(); IgnoredIds = new int[] {}; Paging = new PagingProperties(0, 30, true); SongTypes = new SongType[] {}; }
/// <param name="query">Query search string. Can be null or empty, in which case no filtering by name is done.</param> /// <param name="songTypes">Allowed song types. Can be null or empy, in which case no filtering by song type is done.</param> /// <param name="start">0-based order number of the first item to be returned.</param> /// <param name="maxResults">Maximum number of results to be returned.</param> /// <param name="getTotalCount">Whether to return the total number of entries matching the criteria.</param> /// <param name="nameMatchMode">Mode for name maching. Ignored when query string is null or empty.</param> /// <param name="sortRule">Sort rule for results.</param> /// <param name="moveExactToTop">Whether to move exact match to the top of search results.</param> public ArtistQueryParams(ArtistSearchTextQuery textQuery, ArtistType[] songTypes, int start, int maxResults, bool getTotalCount, ArtistSortRule sortRule, bool moveExactToTop) { Common = CommonSearchParams.Create(textQuery, true, moveExactToTop); Paging = new PagingProperties(start, maxResults, getTotalCount); ArtistTypes = songTypes ?? new ArtistType[] { }; SortRule = sortRule; }
/// <param name="query">Query search string. Can be null or empty, in which case no filtering by name is done.</param> /// <param name="songTypes">Allowed song types. Can be null or empy, in which case no filtering by song type is done.</param> /// <param name="start">0-based order number of the first item to be returned.</param> /// <param name="maxResults">Maximum number of results to be returned.</param> /// <param name="draftsOnly">Whether to return only entries with a draft status.</param> /// <param name="getTotalCount">Whether to return the total number of entries matching the criteria.</param> /// <param name="nameMatchMode">Mode for name maching. Ignored when query string is null or empty.</param> /// <param name="sortRule">Sort rule for results.</param> /// <param name="moveExactToTop">Whether to move exact match to the top of search results.</param> public ArtistQueryParams(string query, ArtistType[] songTypes, int start, int maxResults, bool draftsOnly, bool getTotalCount, NameMatchMode nameMatchMode, ArtistSortRule sortRule, bool moveExactToTop) { Common = new CommonSearchParams(query, draftsOnly, nameMatchMode, true, moveExactToTop); Paging = new PagingProperties(start, maxResults, getTotalCount); ArtistTypes = songTypes ?? new ArtistType[] { }; SortRule = sortRule; }
public AlbumCollectionQueryParams(int userId, PagingProperties paging) { ParamIs.NotNull(() => paging); Paging = paging; UserId = userId; FilterByStatus = PurchaseStatus.Nothing; }
public AlbumQueryParams(SearchTextQuery textQuery, DiscType discType, int start, int maxResults, bool getTotalCount, AlbumSortRule sortRule = AlbumSortRule.Name, bool moveExactToTop = false) { Common = new CommonSearchParams(textQuery, false, moveExactToTop); Paging = new PagingProperties(start, maxResults, getTotalCount); AlbumType = discType; SortRule = sortRule; }
public AlbumQueryParams(string query, DiscType discType, int start, int maxResults, bool draftsOnly, bool getTotalCount, NameMatchMode nameMatchMode = NameMatchMode.Auto, AlbumSortRule sortRule = AlbumSortRule.Name, bool moveExactToTop = false) { Common = new CommonSearchParams(query, draftsOnly, nameMatchMode, false, moveExactToTop); Paging = new PagingProperties(start, maxResults, getTotalCount); AlbumType = discType; SortRule = sortRule; }
public void RetrievePosts_Test() { PagingProperties <Post> pagingProperties = new PagingProperties <Post>(); //Act var result = _postService.Posts(pagingProperties, new PostFilter()); //Assert Assert.AreEqual(2, result.Results.Count); }
public PartialFindResult <CommentForApiContract> GetProfileComments( int id, int start = 0, int maxResults = defaultMax, bool getTotalCount = false ) { var paging = new PagingProperties(start, maxResults, getTotalCount); var result = queries.GetProfileComments(id, paging); return(result); }
public AlbumCollectionQueryParams(int userId, PagingProperties paging) { ParamIs.NotNull(() => paging); Paging = paging; UserId = userId; FilterByStatus = null; Sort = AlbumSortRule.Name; TextQuery = new SearchTextQuery(); }
/// <param name="containerQuery">It is generally used in combosearch which add a parent query that filter table's rows according to query parameter and text field</param> public List <DataModel> GetResult(PagingProperties currentPaging, string containerQuery = null, string[] includes = null) { List <DataModel> dataModel = new List <DataModel>(); DataTable dataTable = new EntityDefEngine(base.EngineSharedModel, base.UnitOfWork).GetEntity(EntityDef, this.Variable, base.AdditionalParams, currentPaging, containerQuery, includes); foreach (DataRow _row in dataTable.Rows) { dataModel.Add(new DataModel(_row)); } return(dataModel); }
public ActionResult EntryEdits(int id = invalidId, bool onlySubmissions = true) { if (id == invalidId) { return(NoId()); } var user = Service.GetUserWithActivityEntries(id, PagingProperties.FirstPage(100), onlySubmissions); return(View(user)); }
public PartialFindResult <AlbumWithAdditionalNamesContract> FindAdvanced( string query, PagingProperties paging, AlbumSortRule sortRule) { return(HandleQuery(session => { var results = FindAdvanced(session, query, paging, sortRule); return new PartialFindResult <AlbumWithAdditionalNamesContract>( results.Items.Select(a => new AlbumWithAdditionalNamesContract(a, PermissionContext.LanguagePreference)).ToArray(), results.TotalCount, results.Term, results.FoundExactMatch); })); }
public RatedSongQueryParams(int userId, PagingProperties paging) { ParamIs.NotNull(() => paging); Paging = paging; UserId = userId; FilterByRating = SongVoteRating.Nothing; GroupByRating = true; SortRule = SongSortRule.Name; }
public AlbumCollectionQueryParams(int userId, PagingProperties paging) { ParamIs.NotNull(() => paging); Paging = paging; UserId = userId; FilterByStatus = null; NameMatchMode = NameMatchMode.Auto; Query = string.Empty; Sort = AlbumSortRule.Name; }
/// <summary> /// Filters query for paging. /// </summary> /// <typeparam name="T">Queried root entity.</typeparam> /// <param name="query">Query. Cannot be null.</param> /// <param name="paging">Paging properties. Can be null.</param> /// <returns>Query which is filtered for paging.</returns> public static IQueryable <T> Paged <T>(this IQueryable <T> query, PagingProperties paging) { if (paging == null) { return(query); } var start = Math.Max(paging.Start, 0); var maxEntries = Math.Max(paging.MaxEntries, 1); return(query.Skip(start).Take(maxEntries)); }
public MikuDbAlbumContract[] GetAlbums(string title, AlbumStatus status, PagingProperties paging) { return(HandleQuery(session => session .Query <MikuDbAlbum>() .Where(a => (string.IsNullOrEmpty(title) || a.Title.Contains(title)) && a.Status == status) .OrderByDescending(a => a.Created) .Skip(paging.Start) .Take(paging.MaxEntries) .ToArray() .Select(a => new MikuDbAlbumContract(a)) .ToArray())); }
public PartialViewResult AlbumsPaged(int id, int?page) { var pageIndex = (page - 1) ?? 0; var queryParams = new AlbumQueryParams { Paging = PagingProperties.CreateFromPage(pageIndex, entriesPerPage, true), SortRule = AlbumSortRule.Name, ArtistId = id }; var result = Services.Albums.Find(queryParams); var data = new PagingData <AlbumContract>(result.Items.ToPagedList(pageIndex, entriesPerPage, result.TotalCount), id, "AlbumsPaged", "ui-tabs-2"); return(PartialView("PagedAlbums", data)); }
public UserMessagesContract GetList(int id, PagingProperties paging, bool unread, IUserIconFactory iconFactory) { PermissionContext.VerifyResourceAccess(new[] { id }); return(HandleQuery(ctx => { var received = GetReceivedMessages(ctx, id, paging, unread, iconFactory); var sent = (!unread ? GetSentMessages(ctx, id, paging, iconFactory) : new UserMessageContract[0]); return new UserMessagesContract { ReceivedMessages = received, SentMessages = sent }; })); }
/// <param name="query">Query search string. Can be null or empty, in which case no filtering by name is done.</param> /// <param name="songTypes">Allowed song types. Can be null or empy, in which case no filtering by song type is done.</param> /// <param name="start">0-based order number of the first item to be returned.</param> /// <param name="maxResults">Maximum number of results to be returned.</param> /// <param name="getTotalCount">Whether to return the total number of entries matching the criteria.</param> /// <param name="nameMatchMode">Mode for name maching. Ignored when query string is null or empty.</param> /// <param name="sortRule">Sort rule for results.</param> /// <param name="onlyByName">Whether to search items only by name, and not for example NicoId. Ignored when query string is null or empty.</param> /// <param name="moveExactToTop">Whether to move exact match to the top of search results.</param> /// <param name="ignoredIds">List of entries to be ignored. Can be null in which case no filtering is done.</param> public SongQueryParams(SearchTextQuery textQuery, SongType[] songTypes, int start, int maxResults, bool getTotalCount, SongSortRule sortRule, bool onlyByName, bool moveExactToTop, int[] ignoredIds) { Common = new CommonSearchParams(textQuery, onlyByName, moveExactToTop); Paging = new PagingProperties(start, maxResults, getTotalCount); SongTypes = songTypes; SortRule = sortRule; IgnoredIds = ignoredIds; TimeFilter = TimeSpan.Zero; OnlyWithPVs = false; }
public PartialViewResult SongsPaged(int id = invalidId, int?page = null) { var pageIndex = (page - 1) ?? 0; var queryParams = new SongQueryParams { Paging = PagingProperties.CreateFromPage(pageIndex, entriesPerPage, true), SortRule = SongSortRule.Name, ArtistId = id }; var result = Services.Songs.Find(queryParams); var data = new PagingData <SongContract>(result.Items.ToPagedList(pageIndex, entriesPerPage, result.TotalCount), id, "SongsPaged", "ui-tabs-3"); return(PartialView("PagedSongs", data)); }
/// <param name="query">Query search string. Can be null or empty, in which case no filtering by name is done.</param> /// <param name="songTypes">Allowed song types. Can be null or empy, in which case no filtering by song type is done.</param> /// <param name="start">0-based order number of the first item to be returned.</param> /// <param name="maxResults">Maximum number of results to be returned.</param> /// <param name="draftsOnly">Whether to return only entries with a draft status.</param> /// <param name="getTotalCount">Whether to return the total number of entries matching the criteria.</param> /// <param name="nameMatchMode">Mode for name maching. Ignored when query string is null or empty.</param> /// <param name="sortRule">Sort rule for results.</param> /// <param name="onlyByName">Whether to search items only by name, and not for example NicoId. Ignored when query string is null or empty.</param> /// <param name="moveExactToTop">Whether to move exact match to the top of search results.</param> /// <param name="ignoredIds">List of entries to be ignored. Can be null in which case no filtering is done.</param> public SongQueryParams(string query, SongType[] songTypes, int start, int maxResults, bool draftsOnly, bool getTotalCount, NameMatchMode nameMatchMode, SongSortRule sortRule, bool onlyByName, bool moveExactToTop, int[] ignoredIds) { Common = new CommonSearchParams(query, draftsOnly, nameMatchMode, onlyByName, moveExactToTop); Paging = new PagingProperties(start, maxResults, getTotalCount); ArtistParticipationStatus = ArtistAlbumParticipationStatus.Everything; SongTypes = songTypes; SortRule = sortRule; IgnoredIds = ignoredIds; TimeFilter = TimeSpan.Zero; OnlyWithPVs = false; }
public PageResult <User> GetAll(string keywordfilter, PagingProperties pagingProperties) { var skip = (pagingProperties.PageNo - 1) * pagingProperties.PageSize; IQueryable <User> items = _context.Users; var totalItems = items.Count(); if (!string.IsNullOrEmpty(keywordfilter)) { items = items.Where(x => x.FullName.Contains(keywordfilter) || x.Username.Contains(keywordfilter)); } items = items.Skip(skip).Take(pagingProperties.PageSize); return(new PageResult <User> { PageItems = items.ToList(), TotalItems = totalItems }); }
public PartialFindResult <TagMappingContract> GetMappings(PagingProperties paging) { return(HandleQuery(ctx => { var query = ctx.Query <TagMapping>(); var result = query .OrderByName(LanguagePreference) .Paged(paging) .ToArray() .Select(t => new TagMappingContract(t, LanguagePreference)) .ToArray(); return PartialFindResult.Create(result, paging.GetTotalCount ? query.Count() : 0); })); }