private static ResourcesPresentationModel PreparePresentationModel(ResourcesPresentationModel model) { // Ensure that the pagination values are always set. if (model == null) { model = new ResourcesPresentationModel(); } if (model.Pagination == null) { model.Pagination = new Pagination(); } if (model.Pagination.Page == null) { model.Pagination.Page = 1; } if (model.Pagination.Items == null) { model.Pagination.Items = DefaultItemsPerPage; } model.ItemsPerPage = Reference.ItemsPerPage; model.DefaultItemsPerPage = DefaultItemsPerPage; return(model); }
private ResourceListModel <TResource> PartialRecentResources <TResource>(ResourcesPresentationModel presentation, Func <Guid, IList <TResource> > getRecentlyViewedResources) where TResource : Resource { presentation = PreparePresentationModel(presentation); var user = CurrentUser; // Get the resources. var model = GetRecentlyViewedResources(user.Id, presentation, getRecentlyViewedResources); // Set the data for all resources in the model. return(GetPartialResourceListModel(user, model)); }
public ActionResult CategoryVideos(ResourceSearchCriteria criteria, ResourcesPresentationModel presentation) { return(Videos(criteria, presentation)); }
public ActionResult QnAs(ResourceSearchCriteria criteria, ResourcesPresentationModel presentation) { return(View("QnAs", Resources(criteria, presentation, i => _resourcesQuery.GetQnAs(i), u => _resourcesQuery.GetRecentlyViewedQnAs(u, RecentItemsCount)))); }
private ResourceListModel <TResource> GetRecentlyViewedResources <TResource>(Guid userId, ResourcesPresentationModel presentation, Func <Guid, IList <TResource> > getRecentlyViewedResources) where TResource : Resource { var results = getRecentlyViewedResources(userId); return(new ResourceListModel <TResource> { Categories = _resourcesQuery.GetCategories(), Presentation = presentation, Criteria = new ResourceSearchCriteria { ResourceType = GetResourceType <TResource>() }, Results = new ResourceListResultsModel <TResource> { ResourceIds = results.Select(r => r.Id).ToList(), Resources = results.ToDictionary(r => r.Id, r => r), }, }); }
private ResourceListModel <TResource> Search <TResource>(Guid userId, ResourceSearchCriteria criteria, ResourcesPresentationModel presentation, IList <Category> categories, Func <IList <Guid>, IList <TResource> > getResources, Func <Guid, IList <TResource> > getRecentlyViewedResources) where TResource : Resource { // Search. var execution = _executeResourceSearchCommand.Search(criteria, presentation.Pagination.ToRange()); return(new ResourceListModel <TResource> { Categories = categories, Presentation = presentation, Criteria = execution.Criteria, TotalResources = execution.Results.ResourceTypeHits.ToDictionary(h => h.Key, h => h.Value), Results = new ResourceListResultsModel <TResource> { ResourceIds = execution.Results.ResourceIds, Resources = getResources(execution.Results.ResourceIds).ToDictionary(r => r.Id, r => r), }, RecentItems = getRecentlyViewedResources(userId).Cast <Resource>().ToList(), }); }
private ResourceListModel <TResource> PartialResources <TResource>(ResourceSearchCriteria criteria, ResourcesPresentationModel presentation, Func <IList <Guid>, IList <TResource> > getResources, Func <Guid, IList <TResource> > getRecentlyViewedResources) where TResource : Resource { // Save the current search. criteria.ResourceType = GetResourceType <TResource>(); criteria.SortCriteria = new ResourceSearchSortCriteria { SortOrder = ResourceSortOrder.CreatedTime, ReverseSortOrder = false }; presentation = PreparePresentationModel(presentation); MemberContext.CurrentResourcesSearch = new ResourcesSearchNavigation(criteria, presentation); // Search. var user = CurrentUser; var categories = _resourcesQuery.GetCategories(); var model = Search(user.Id, criteria, presentation, categories, getResources, getRecentlyViewedResources); // Set the data for all resources in the model. return(GetPartialResourceListModel(user, model)); }
public ActionResult PartialRecentQnAs(ResourcesPresentationModel presentation) { return(PartialView(PartialRecentResources(presentation, u => _resourcesQuery.GetRecentlyViewedQnAs(u, RecentItemsCount)))); }
public ActionResult PartialVideos(ResourceSearchCriteria criteria, ResourcesPresentationModel presentation) { return(PartialView("PartialVideos", PartialResources(criteria, presentation, i => _resourcesQuery.GetVideos(i), u => _resourcesQuery.GetRecentlyViewedVideos(u, RecentItemsCount)))); }