async Task <TagIndexViewModel <Tag> > GetViewModel(TagIndexOptions options, PagerOptions pager) { // Get tags var results = await _tagService.GetResultsAsync(options, pager); // Set total on pager pager.SetTotal(results?.Total ?? 0); // Return view model return(new TagIndexViewModel <Tag>() { Results = results, Options = options, Pager = pager }); }
async Task <LabelIndexViewModel <Label> > GetViewModel(LabelIndexOptions options, PagerOptions pager) { var results = await _labelService .GetResultsAsync(options, pager); // Set total on pager pager.SetTotal(results?.Total ?? 0); // Return view model return(new LabelIndexViewModel <Label> { Results = results, Options = options, Pager = pager }); }
async Task <EntityViewModel <Topic, Reply> > GetViewModel(EntityOptions options, PagerOptions pager) { var topic = await _entityStore.GetByIdAsync(options.Id); if (topic == null) { throw new ArgumentNullException(); } var results = await _replyService .ConfigureQuery(async q => { // Hide private? if (!await _authorizationService.AuthorizeAsync(HttpContext.User, Permissions.ViewHiddenTopics)) { q.HideHidden.True(); } // Hide spam? if (!await _authorizationService.AuthorizeAsync(HttpContext.User, Permissions.ViewSpamTopics)) { q.HideSpam.True(); } // Hide deleted? if (!await _authorizationService.AuthorizeAsync(HttpContext.User, Permissions.ViewDeletedTopics)) { q.HideDeleted.True(); } }) .GetResultsAsync(options, pager); // Set total on pager pager.SetTotal(results?.Total ?? 0); // Return view model return(new EntityViewModel <Topic, Reply> { Options = options, Pager = pager, Entity = topic, Replies = results }); }
private async Task <UserIndexViewModel> GetIndexViewModel(UserIndexOptions options, PagerOptions pager) { var results = await _userService .ConfigureQuery(async q => { // Hide unconfirmed? if (!await _authorizationService.AuthorizeAsync(HttpContext.User, Permissions.ViewUnconfirmedUsers)) { q.HideUnconfirmed.True(); } // Hide SPAM? if (!await _authorizationService.AuthorizeAsync(HttpContext.User, Permissions.ViewSpamUsers)) { q.HideSpam.True(); } // Hide Banned? if (!await _authorizationService.AuthorizeAsync(HttpContext.User, Permissions.ViewBannedUsers)) { q.HideBanned.True(); } }) .GetResultsAsync(options, pager); // Set total on pager pager.SetTotal(results?.Total ?? 0); // Return view model return(new UserIndexViewModel { SortColumns = _defaultSortColumns, SortOrder = _defaultSortOrder, Filters = _defaultFilters, Results = results, Options = options, Pager = pager }); }
async Task <EntityIndexViewModel <Article> > GetViewModel( EntityIndexOptions options, PagerOptions pager) { // Get results var results = await _articleService .ConfigureQuery(async q => { // Hide private? if (!await _authorizationService.AuthorizeAsync(HttpContext.User, Permissions.ViewHiddenArticles)) { q.HideHidden.True(); } // Hide spam? if (!await _authorizationService.AuthorizeAsync(HttpContext.User, Permissions.ViewSpamArticles)) { q.HideSpam.True(); } // Hide deleted? if (!await _authorizationService.AuthorizeAsync(HttpContext.User, Permissions.ViewDeletedArticles)) { q.HideDeleted.True(); } }) .GetResultsAsync(options, pager); // Set total on pager pager.SetTotal(results?.Total ?? 0); // Return view model return(new EntityIndexViewModel <Article>() { Results = results, Options = options, Pager = pager }); }