Пример #1
0
        // ---------------

        async Task <TagIndexViewModel <Tag> > GetIndexViewModelAsync(TagIndexOptions options, PagerOptions pager)
        {
            // Get current feature
            var feature = await _featureFacade.GetFeatureByIdAsync("Plato.Discuss");

            // Restrict results to current feature
            if (feature != null)
            {
                options.FeatureId = feature.Id;
            }

            if (options.Sort == TagSortBy.Auto)
            {
                options.Sort  = TagSortBy.Entities;
                options.Order = OrderBy.Desc;
            }

            // Set pager call back Url
            pager.Url = _contextFacade.GetRouteUrl(pager.Route(RouteData));

            return(new TagIndexViewModel <Tag>()
            {
                Options = options,
                Pager = pager
            });
        }
Пример #2
0
        async Task <EntityIndexViewModel <Entity> > GetIndexViewModelAsync(EntityIndexOptions options, PagerOptions pager)
        {
            // Set default sort column if auto is specified
            if (options.Sort == SortBy.LastReply)
            {
                // Get search settings
                var searchSettings = await _searchSettingsStore.GetAsync();

                if (searchSettings != null)
                {
                    options.Sort = searchSettings.SearchType == SearchTypes.Tsql
                        ? SortBy.LastReply
                        : SortBy.Rank;
                }
                else
                {
                    options.Sort = SortBy.LastReply;
                }
            }

            // Set pager call back Url
            pager.Url = _contextFacade.GetRouteUrl(pager.Route(this.RouteData));

            // Return updated model
            return(new EntityIndexViewModel <Entity>()
            {
                Options = options,
                Pager = pager
            });
        }
Пример #3
0
        //// ----------------------

        Task <ReportIndexViewModel <Metric> > GetIndexViewModelAsync(ReportOptions options, PagerOptions pager)
        {
            // Set pager call back Url
            pager.Url = _contextFacade.GetRouteUrl(pager.Route(RouteData));

            // Return updated model
            return(Task.FromResult(new ReportIndexViewModel <Metric>()
            {
                Options = options,
                Pager = pager
            }));
        }
Пример #4
0
        EntityIndexViewModel <Entity> GetIndexViewModel(EntityIndexOptions options, PagerOptions pager)
        {
            // Set pager call back Url
            pager.Url = _contextFacade.GetRouteUrl(pager.Route(RouteData));

            // Return updated model
            return(new EntityIndexViewModel <Entity>()
            {
                Options = options,
                Pager = pager
            });
        }
Пример #5
0
        private async Task <EntityIndexViewModel <Doc> > GetIndexViewModelAsync(Category category, EntityIndexOptions options, PagerOptions pager)
        {
            // Include child categories
            if (category != null)
            {
                if (category.Children.Any())
                {
                    // Convert child ids to list and add current id
                    var ids = category
                              .Children
                              .Select(c => c.Id).ToList();
                    ids.Add(category.Id);
                    options.CategoryIds = ids.ToArray();
                }
                else
                {
                    options.CategoryId = category.Id;
                }
            }
            else
            {
                options.CategoryId = 0;
            }

            // Get current feature
            var feature = await _featureFacade.GetFeatureByIdAsync("Plato.Docs");

            // Restrict results to current feature
            if (feature != null)
            {
                options.FeatureId = feature.Id;
            }

            // Ensure pinned entities appear first
            if (options.Sort == SortBy.LastReply)
            {
                options.SortColumns.Add(SortBy.IsPinned.ToString(), OrderBy.Desc);
            }

            // Set pager call back Url
            pager.Url = _contextFacade.GetRouteUrl(pager.Route(RouteData));

            // Return updated model
            return(new EntityIndexViewModel <Doc>()
            {
                Options = options,
                Pager = pager
            });
        }
Пример #6
0
        async Task <EntityIndexViewModel <Issue> > GetDisplayViewModelAsync(EntityIndexOptions options, PagerOptions pager)
        {
            // Get feature
            options.FeatureId = await GetFeatureIdAsync();

            // Set pager call back Url
            pager.Url = _contextFacade.GetRouteUrl(pager.Route(RouteData));

            // Return updated model
            return(new EntityIndexViewModel <Issue>()
            {
                Options = options,
                Pager = pager
            });
        }
Пример #7
0
        async Task <LabelIndexViewModel <Label> > GetIndexViewModelAsync(LabelIndexOptions options, PagerOptions pager)
        {
            // Get discuss feature
            options.FeatureId = await GetFeatureIdAsync();

            if (options.Sort == LabelSortBy.Auto)
            {
                options.Sort = LabelSortBy.Entities;
            }

            // Set pager call back Url
            pager.Url = _contextFacade.GetRouteUrl(pager.Route(RouteData));

            return(new LabelIndexViewModel <Label>()
            {
                Options = options,
                Pager = pager
            });
        }
Пример #8
0
        async Task <EntityIndexViewModel <Topic> > GetDisplayViewModelAsync(EntityIndexOptions options, PagerOptions pager)
        {
            // Get current feature
            var feature = await _featureFacade.GetFeatureByIdAsync("Plato.Discuss");

            // Restrict results to current feature
            if (feature != null)
            {
                options.FeatureId = feature.Id;
            }

            // Set pager call back Url
            pager.Url = _contextFacade.GetRouteUrl(pager.Route(RouteData));

            return(new EntityIndexViewModel <Topic>()
            {
                Options = options,
                Pager = pager
            });
        }
Пример #9
0
        async Task <EntityIndexViewModel <Article> > GetIndexViewModelAsync(EntityIndexOptions options, PagerOptions pager)
        {
            // Get current feature
            var feature = await _featureFacade.GetFeatureByIdAsync(RouteData.Values["area"].ToString());

            // Restrict results to current feature
            if (feature != null)
            {
                options.FeatureId = feature.Id;
            }

            // Set pager call back Url
            pager.Url = _contextFacade.GetRouteUrl(pager.Route(RouteData));

            // Return updated model
            return(new EntityIndexViewModel <Article>()
            {
                Options = options,
                Pager = pager
            });
        }
Пример #10
0
        // ------------

        async Task <TagIndexViewModel <Tag> > GetIndexViewModelAsync(TagIndexOptions options, PagerOptions pager)
        {
            // Get feature
            options.FeatureId = await GetFeatureIdAsync();

            if (options.Sort == TagSortBy.Auto)
            {
                options.Sort  = TagSortBy.Modified;
                options.Order = OrderBy.Desc;
            }

            // Indicate administrator view
            options.EnableEdit = true;

            // Set pager call back Url
            pager.Url = _contextFacade.GetRouteUrl(pager.Route(RouteData));

            return(new TagIndexViewModel <Tag>()
            {
                Options = options,
                Pager = pager
            });
        }