public ActionResult List(ListContentsViewModel model, PagerParameters pagerParameters) { var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var query = _contentManager.Query<ProductPart, ProductPartRecord>(VersionOptions.Latest); switch (model.Options.OrderBy) { case ContentsOrder.Modified: query.OrderByDescending<CommonPartRecord>(cr => cr.ModifiedUtc); break; case ContentsOrder.Published: query.OrderByDescending<CommonPartRecord>(cr => cr.PublishedUtc); break; case ContentsOrder.Created: query.OrderByDescending<CommonPartRecord>(cr => cr.CreatedUtc); break; } var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count()); var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList(); var list = Shape.List(); list.AddRange(pageOfContentItems.Select(ci => _contentManager.BuildDisplay(ci, "SummaryAdmin"))); dynamic viewModel = Shape.ViewModel() .ContentItems(list) .Pager(pagerShape) .Options(model.Options); // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation. return View((object)viewModel); }
public ActionResult Index(PagerParameters pagerParameters, string q = "") { var cleanQ = AntiXssEncoder.HtmlEncode(q, true); // ensure the search query is properly encoded to prevent XSS var searchSettingPart = Services.WorkContext.CurrentSite.As<SearchSettingsPart>(); if (String.IsNullOrEmpty(searchSettingPart.SearchIndex)) { Services.Notifier.Error(T("Please define a default search index")); return HttpNotFound(); } List<string> contentTypes = new List<string>() { "Event", "Community", "CodeSample", "PatternsAndPractices", "Podcast", "Resource", "Solution", "StepPage", "Training", "VideoItem", "Article" }; var results = new List<ContentTypeResults>(); results = GetSearchResults(cleanQ, pagerParameters, searchSettingPart, contentTypes); var searchViewModel = new SearchViewModel { Query = cleanQ, FilteredItems = results }; //todo: deal with page requests beyond result count return View(searchViewModel); }
public ActionResult Item(string blogPath, PagerParameters pagerParameters) { Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var correctedPath = _blogPathConstraint.FindPath(blogPath); if (correctedPath == null) return HttpNotFound(); var blogPart = _blogService.Get(correctedPath); if (blogPart == null) return HttpNotFound(); // primary action run for a home paged item shall not pass if (!RouteData.DataTokens.ContainsKey("ParentActionViewContext") && blogPart.Id == _routableHomePageProvider.GetHomePageId(_workContextAccessor.GetContext().CurrentSite.HomePage)) { return HttpNotFound(); } _feedManager.Register(blogPart); var blogPosts = _blogPostService.Get(blogPart, pager.GetStartIndex(), pager.PageSize) .Select(b => _services.ContentManager.BuildDisplay(b, "Summary")); dynamic blog = _services.ContentManager.BuildDisplay(blogPart); var list = Shape.List(); list.AddRange(blogPosts); blog.Content.Add(Shape.Parts_Blogs_BlogPost_List(ContentItems: list), "5"); var totalItemCount = _blogPostService.PostCount(blogPart); blog.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after"); return new ShapeResult(this, blog); }
public ActionResult Index(PagerParameters pagerParameters, AuditTrailOrderBy? orderBy = null) { if (!_authorizer.Authorize(Permissions.ViewAuditTrail)) return new HttpUnauthorizedResult(); var viewModel = SetupViewModel(new RecycleBinViewModel(), pagerParameters); return View(viewModel); }
public ActionResult MyPackages(PagerParameters pagerParameters) { Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); IUser authenticatedUser = _authenticationService.GetAuthenticatedUser(); var key = _userkeyService.GetAccessKeyForUser(authenticatedUser.Id); dynamic list = _services.New.List(); int startingPackageIndex = pager.GetStartIndex(); IEnumerable<PackagePart> packages = GetPublishedPackagesUserCanManage(authenticatedUser, key, startingPackageIndex, pager.PageSize); int totalPackageCount = GetCountOfPublishedPackagesUserCanManage(authenticatedUser, key); IEnumerable<PackagePart> unpublishedPackages = GetUnpublishedPackagesUserCanManage(authenticatedUser, key); list.AddRange(packages.Select(p => { dynamic packageShape = _services.ContentManager.BuildDisplay(p, "SummaryOwner"); packageShape.HasTags = p.As<TagsPart>().CurrentTags.Count() > 0; return packageShape; } )); var viewModel = new MyPackagesViewModel { Packages = list, TotalNumberOfPackages = totalPackageCount, StartingNumber = startingPackageIndex + 1, EndingNumber = totalPackageCount < startingPackageIndex + pager.PageSize ? totalPackageCount : startingPackageIndex + pager.PageSize, Pager = Shape.Pager(pager).TotalItemCount(totalPackageCount), UnpublishedPackages = unpublishedPackages }; return View(viewModel); }
public ActionResult Index(int? countryId, PagerParameters pagerParameters) { var viewModel = new DeliverySettingsViewModel { CountryId = countryId, CountryRepository = _countryRepository }; var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize); //var setting = _deliverySettingsRepository.Table.Where(s => s.DeliveryCulture == cultureUsed); //if (setting.FirstOrDefault() == null) // { // _deliverySettingService.AddSetting("Default", 0, 0, 1, cultureUsed); // } var allCountrySettings = _deliverySettingsRepository.Table.Where(s => s.Country.Id == (countryId ?? 0)); viewModel.DeliverySettings = allCountrySettings .OrderBy(a => a.State) .Skip(pager.GetStartIndex()) .Take(pager.PageSize); var pagerShape = Shape.Pager(pager).TotalItemCount(allCountrySettings.Count()); viewModel.Pager = pagerShape; return View(viewModel); }
public ActionResult Item(string TimetableSlug, PagerParameters pagerParameters) { Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var correctedSlug = _TimetableSlugConstraint.FindSlug(TimetableSlug); if (correctedSlug == null) return HttpNotFound(); var TimetablePart = _TimetableService.Get(correctedSlug); if (TimetablePart == null) return HttpNotFound(); if (!RouteData.DataTokens.ContainsKey("ParentActionViewContext") && TimetablePart.Id == _routableHomePageProvider.GetHomePageId(_workContextAccessor.GetContext().CurrentSite.HomePage)) { return HttpNotFound(); } _feedManager.Register(TimetablePart); var TimetableAppointments = _TimetableAppointmentService.Get(TimetablePart, pager.GetStartIndex(), pager.PageSize) //.Select(b => _services.ContentManager.BuildDisplay(b, "Summary")); .Select(b => b); dynamic Timetable = _services.ContentManager.BuildDisplay(TimetablePart); var list = Shape.List(); list.AddRange(TimetableAppointments); Timetable.Content.Add(Shape.Parts_Timetables_TimetableAppointment_List(ContentItems: list), "5"); var totalItemCount = _TimetableAppointmentService.AppointmentCount(TimetablePart); Timetable.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after"); return View((object)Timetable); }
public ActionResult Item(int blogId, PagerParameters pagerParameters) { Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var blogPart = _blogService.Get(blogId, VersionOptions.Published).As<BlogPart>(); if (blogPart == null) return HttpNotFound(); if (!_services.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent, blogPart, T("Cannot view content"))) { return new HttpUnauthorizedResult(); } _feedManager.Register(blogPart, _services.ContentManager.GetItemMetadata(blogPart).DisplayText); var blogPosts = _blogPostService.Get(blogPart, pager.GetStartIndex(), pager.PageSize) .Select(b => _services.ContentManager.BuildDisplay(b, "Summary")); dynamic blog = _services.ContentManager.BuildDisplay(blogPart); var list = Shape.List(); list.AddRange(blogPosts); blog.Content.Add(Shape.Parts_Blogs_BlogPost_List(ContentItems: list), "5"); var totalItemCount = _blogPostService.PostCount(blogPart); blog.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after"); return new ShapeResult(this, blog); }
public ActionResult EditCategory(PagerParameters pagerParameters, int id, string searchString) { var camps = _campCategService.GetCampaignsByIdCategory(id).ToList(); CampaignCategoriesRecord category = _campCategService.GetCategoryById(id); if (!string.IsNullOrEmpty(searchString)) { camps = camps.Where(c => c.Title.ToLower().Contains(searchString.ToLower())).OrderByDescending(c => c.ProductCountSold).OrderBy(c => c.Title).ToList(); } var entriesProjection = camps.Select(e => { return Shape.FaqEntry( Id: e.Id, Title: e.Title, ProductCountSold: e.ProductCountSold, ProductCountGoal: e.ProductCountGoal ); }); var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize); var entries = entriesProjection.Skip(pager.GetStartIndex()).Take(pager.PageSize); var pagerShape = Shape.Pager(pager).TotalItemCount(entriesProjection.Count()); return View("EditCategory", new AdminSearchViewModel { Camapigns = entries.ToArray(), CategoryId = id, CategoryName = category.Name, Pager = pagerShape }); }
public ActionResult ShowFormResults(int id, PagerParameters pagerParameters) { if (!_services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to view form results"))) return new HttpUnauthorizedResult(); var form = _services.ContentManager.Get<OFormPart>(id, VersionOptions.Latest); if (form == null) return HttpNotFound(); CheckValidSerial(); var pager = new Pager(_services.WorkContext.CurrentSite, pagerParameters); var formResults = _resultsRepo.Table.Where(x => x.OFormPartRecord == form.Record); var pagerShape = Shape.Pager(pager).TotalItemCount(formResults.Count()); var results = formResults .OrderByDescending(x => x.CreatedDate) .Skip(pager.GetStartIndex()).Take(pager.PageSize); return View(new FormResultViewModel { FormId = form.Id, FormName = form.Name, Results = results.ToList(), Pager = pagerShape }); }
public ActionResult Search(string tagName, PagerParameters pagerParameters) { Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var tag = _tagService.GetTagByName(tagName); if (tag == null) { return RedirectToAction("Index"); } var taggedItems = _tagService.GetTaggedContentItems(tag.Id, pager.GetStartIndex(), pager.PageSize) .Select(item => _contentManager.BuildDisplay(item, "Summary")); var list = _shapeFactory.List(); list.AddRange(taggedItems); var totalItemCount = _tagService.GetTaggedContentItemCount(tag.Id); var viewModel = new TagsSearchViewModel { TagName = tag.TagName, List = list, Pager = _shapeFactory.Pager(pager).TotalItemCount(totalItemCount) }; return View(viewModel); }
public ActionResult Item(int forumId, PagerParameters pagerParameters) { var forumPart = _forumService.Get(forumId, VersionOptions.Published); if (forumPart == null) return HttpNotFound(); if (!_orchardServices.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent, forumPart, T("Not allowed to view forum"))) return new HttpUnauthorizedResult(); Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var threads = _threadService .Get(forumPart, pager.GetStartIndex(), pager.PageSize, VersionOptions.Published) .Select(b => _orchardServices.ContentManager.BuildDisplay(b, "Summary")); dynamic forum = _orchardServices.ContentManager.BuildDisplay(forumPart); var list = Shape.List(); list.AddRange(threads); forum.Content.Add(Shape.Parts_Forums_Thread_List(ContentPart: forumPart, ContentItems: list), "5"); var totalItemCount = forumPart.ThreadCount; forum.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after"); return new ShapeResult(this, forum); }
public ActionResult ExecuteAction(RecycleBinViewModel viewModel, PagerParameters pagerParameters) { if (viewModel.RecycleBinCommand == null) { ModelState.AddModelError("RecycleBinCommand", T("Please select an action to execute.").Text); } if (viewModel.SelectedContentItems == null || !viewModel.SelectedContentItems.Any()) { ModelState.AddModelError("SelectedContentItems", T("Please select one or more content items.").Text); } if (!ModelState.IsValid) { SetupViewModel(viewModel, pagerParameters); return View("Index", viewModel); } if (ModelState.IsValid) { var selectedContentItemIds = viewModel.SelectedContentItems.Where(x => x.Selected).Select(x => x.Id).ToArray(); switch (viewModel.RecycleBinCommand) { case RecycleBinCommand.Restore: RestoreContentItems(selectedContentItemIds); break; case RecycleBinCommand.Destroy: DeleteContentItems(selectedContentItemIds); break; } } return RedirectToAction("Index"); }
public ActionResult Index(PagerParameters pagerParameters, string type = "Module", string q = "", string s = "") { var pager = new Pager(_orchardService.WorkContext.CurrentSite, pagerParameters); var searchBuilder = GetSearchBuilder(); if (!String.IsNullOrWhiteSpace(q)) { foreach (var field in new[] { "body", "title", "tags", "package-id" }) { searchBuilder.Parse( defaultField: field, query: q, escape: true ).AsFilter(); } } searchBuilder.WithField("package-extension-type", type.ToLowerInvariant()).NotAnalyzed().ExactMatch(); // Only apply custom order if there is no search filter. Otherwise some oddly related packages // might appear at the top. if (String.IsNullOrWhiteSpace(q) && !String.IsNullOrWhiteSpace(s)) { switch (s) { case "download": searchBuilder.SortByInteger("package-download-count"); break; default: // Order by relevance by default. break; } } else if(String.IsNullOrWhiteSpace(q) && String.IsNullOrWhiteSpace(s)) { searchBuilder.SortByInteger("package-download-count"); } var count = searchBuilder.Count(); var pageOfResults = searchBuilder.Slice((pager.Page - 1) * pager.PageSize, pager.PageSize).Search(); var list = _orchardService.New.List(); var foundIds = pageOfResults.Select(searchHit => searchHit.ContentItemId).ToList(); var foundItems = _orchardService.ContentManager.GetMany<IContent>(foundIds, VersionOptions.Published, new QueryHints()).ToList(); foreach (var contentItem in foundItems) { list.Add(_orchardService.ContentManager.BuildDisplay(contentItem, "Summary")); } var pagerShape = _orchardService.New.Pager(pager).TotalItemCount(count); var searchViewModel = _orchardService.New.ViewModel( Query: q, TotalItemCount: count, StartPosition: (pager.Page - 1) * pager.PageSize + 1, EndPosition: pager.Page * pager.PageSize > count ? count : pager.Page * pager.PageSize, ContentItems: list, Pager: pagerShape, Type: type ); return View(searchViewModel); }
public ActionResult List(string packageType, PagerParameters pagerParameters) { var viewModel = BuildList(string.Empty, packageType, string.Empty, pagerParameters, SORT_BY_DOWNLOAD_COUNT); if (viewModel == null) { throw new HttpException(404, ""); } viewModel.SearchTarget = packageType; return View(viewModel); }
public ActionResult List(ListContentsViewModel model, PagerParameters pagerParameters) { var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var container = model.ContainerId.HasValue ? _contentManager.GetLatest((int)model.ContainerId) : null; if (container == null || !container.Has<ContainerPart>()) { return HttpNotFound(); } var restrictedContentType = container.As<ContainerPart>().Record.ItemContentType; var hasRestriction = !string.IsNullOrEmpty(restrictedContentType); if (hasRestriction) { model.FilterByContentType = restrictedContentType; } model.Options.SelectedFilter = model.FilterByContentType; model.ContainerDisplayName = container.ContentManager.GetItemMetadata(container).DisplayText; if (string.IsNullOrEmpty(model.ContainerDisplayName)) { model.ContainerDisplayName = container.ContentType; } var query = GetListContentItemQuery(model.ContainerId.Value, model.FilterByContentType, model.Options.OrderBy); if (query == null) { return HttpNotFound(); } model.Options.FilterOptions = GetContainableTypes() .Select(ctd => new KeyValuePair<string, string>(ctd.Name, ctd.DisplayName)) .ToList().OrderBy(kvp => kvp.Key); var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count()); var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList(); var list = Shape.List(); list.AddRange(pageOfContentItems.Select(ci => _contentManager.BuildDisplay(ci, "SummaryAdmin"))); var containerItemContentDisplayName = String.Empty; if (hasRestriction) containerItemContentDisplayName = _contentDefinitionManager.GetTypeDefinition(restrictedContentType).DisplayName; else if (!string.IsNullOrEmpty(model.FilterByContentType)) containerItemContentDisplayName = _contentDefinitionManager.GetTypeDefinition(model.FilterByContentType).DisplayName; dynamic viewModel = Shape.ViewModel() .ContentItems(list) .Pager(pagerShape) .ContainerId(model.ContainerId) .Options(model.Options) .ContainerDisplayName(model.ContainerDisplayName) .HasRestriction(hasRestriction) .ContainerContentType(container.ContentType) .ContainerItemContentDisplayName(containerItemContentDisplayName) .ContainerItemContentType(hasRestriction ? restrictedContentType : (model.FilterByContentType ?? "")) .OtherLists(_contentManager.Query<ContainerPart>(VersionOptions.Latest).List() .Select(part => part.ContentItem) .Where(item => item != container) .OrderBy(item => item.As<CommonPart>().VersionPublishedUtc)); // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation. return View((object)viewModel); }
public ActionResult Index(PagerParameters pagerParameters) { var actorTable = GetActorTableShape(pagerParameters, string.Empty); var viewModel = Shape.ViewModel(); viewModel.ActorTable(actorTable); return View(viewModel); }
public ActionResult Index(PagerParameters pagerParameters) { var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize); var ordersQuery = _orderService.GetOrders().List().OrderByDescending(o => o.CreatedAt); var orders = ordersQuery.Skip(pager.GetStartIndex()).Take(pager.PageSize); var pagerShape = Shape.Pager(pager).TotalItemCount(ordersQuery.Count()); var model = Shape.Orders(Orders: orders.ToArray(), Pager: pagerShape); return View((object)model); }
public ActionResult Index(SpamIndexOptions options, PagerParameters pagerParameters) { if (!Services.Authorizer.Authorize(Permissions.ManageAntiSpam, T("Not authorized to manage spam"))) return new HttpUnauthorizedResult(); var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); // default options if (options == null) options = new SpamIndexOptions(); var query = Services.ContentManager.Query().ForPart<SpamFilterPart>(); switch(options.Filter) { case SpamFilter.Spam: query = query.Where<SpamFilterPartRecord>(x => x.Status == SpamStatus.Spam); break; case SpamFilter.Ham: query = query.Where<SpamFilterPartRecord>(x => x.Status == SpamStatus.Ham); break; case SpamFilter.All: break; default: throw new ArgumentOutOfRangeException(); } var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count()); switch (options.Order) { case SpamOrder.Creation: query = query.Join<CommonPartRecord>().OrderByDescending(u => u.CreatedUtc); break; } var results = query .Slice(pager.GetStartIndex(), pager.PageSize); var model = new SpamIndexViewModel { Spams = results.Select(x => new SpamEntry { Spam = x.As<SpamFilterPart>(), Shape = Services.ContentManager.BuildDisplay(x, "SummaryAdmin") }).ToList(), Options = options, Pager = pagerShape }; // maintain previous route data when generating page links var routeData = new RouteData(); routeData.Values.Add("Options.Filter", options.Filter); routeData.Values.Add("Options.Search", options.Search); routeData.Values.Add("Options.Order", options.Order); pagerShape.RouteData(routeData); return View(model); }
public ActionResult Index(ListContentsViewModel model, PagerParameters pagerParameters) { var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var query = Services.ContentManager.Query(VersionOptions.Latest, GetCreatableTypes(false).Select(ctd => ctd.Name).ToArray()); if (!string.IsNullOrEmpty(model.Options.SelectedFilter)) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(model.Options.SelectedFilter); if (contentTypeDefinition == null) return HttpNotFound(); model.TypeDisplayName = !string.IsNullOrWhiteSpace(contentTypeDefinition.DisplayName) ? contentTypeDefinition.DisplayName : contentTypeDefinition.Name; query = query.ForType(model.Options.SelectedFilter); } switch (model.Options.OrderBy) { case ContentsOrder.Modified: query = query.OrderByDescending<CommonPartRecord>(cr => cr.ModifiedUtc); break; case ContentsOrder.Published: query = query.OrderByDescending<CommonPartRecord>(cr => cr.PublishedUtc); break; case ContentsOrder.Created: query = query.OrderByDescending<CommonPartRecord>(cr => cr.CreatedUtc); break; } model.Options.FilterOptions = GetCreatableTypes(false) .Select(ctd => new KeyValuePair<string, string>(ctd.Name, ctd.DisplayName)) .ToList().OrderBy(kvp => kvp.Value); var pagerShape = Services.New.Pager(pager).TotalItemCount(query.Count()); var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList(); var list = Services.New.List(); list.AddRange(pageOfContentItems.Select(ci => Services.ContentManager.BuildDisplay(ci, "SummaryAdmin"))); foreach(IShape item in list.Items) { item.Metadata.Type = "ContentPicker"; } dynamic tab = Services.New.RecentContentTab() .ContentItems(list) .Pager(pagerShape) .Options(model.Options) .TypeDisplayName(model.TypeDisplayName ?? ""); // retain the parameter in the pager links RouteData.Values["Options.SelectedFilter"] = model.Options.SelectedFilter; RouteData.Values["Options.OrderBy"] = model.Options.OrderBy.ToString(); return new ShapeResult(this, Services.New.ContentPicker().Tab(tab)); }
public ActionResult Index(string id, PagerParameters pagerParameters) { var pager = new Pager(_services.WorkContext.CurrentSite, pagerParameters); var submissions = _formService.GetSubmissions(id, pager.GetStartIndex(), pager.PageSize); var pagerShape = _services.New.Pager(pager).TotalItemCount(submissions.TotalItemCount); var viewModel = new SubmissionsIndexViewModel { FormName = id, Submissions = _formService.GenerateDataTable(submissions), Pager = pagerShape }; return View(viewModel); }
public ActionResult Display(int id, PagerParameters pagerParameters) { var container = _contentManager.Get(id).As<ContainerPart>(); if (container==null) return HttpNotFound(T("Container not found").Text); // TODO: (PH) Find a way to apply PagerParameters via a driver so we can lose this controller container.PagerParameters = pagerParameters; var model = _contentManager.BuildDisplay(container, "Detail"); return new ShapeResult(this, model); }
public ActionResult Index(PagerParameters pagerParameters) { Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var contactEntryCount = _contactFormService.GetEntries().Count(); var entries = _contactFormService.GetEntries().ToList();//.Select(e => _contactFormService.Convert(e)).ToList(); // TODO add paging; var pagerShape = Shape.Pager(pager).TotalItemsCount(contactEntryCount); var vm = new ContactFormEntryListViewModel { ContactFormEntries = entries, Pager = pager }; return View(vm); //return null; }
public ActionResult ListPostReports(ReportPostSearchViewModel model, PagerParameters pagerParameters) { if (!_orchardServices.Authorizer.Authorize(Permissions.ModerateInappropriatePosts, T("You do not have the proper permissions to administer inappropriate posts"))) return new HttpUnauthorizedResult(); Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); if (!_orchardServices.WorkContext.HttpContext.User.Identity.IsAuthenticated) return new HttpUnauthorizedResult(T("You must be logged in").ToString()); if (Request.QueryString["ShowUnresolvedOnly"] != null) { model.ShowUnresolvedOnly = Request.QueryString["ShowUnresolvedOnly"].ToLower().Contains("true"); ; } IEnumerable<ReportedPostEntry> searchResults = new List<ReportedPostEntry>(); int totalItemCount = 0; if (!string.IsNullOrEmpty(model.SearchButton) ) { var results = _reportPostService.GetPostReports( model.PostId, model.StartDate, model.EndDate, model.ReportedByUserName, model.ReviewedByUserName, model.ReportedUserName, model.ShowUnresolvedOnly, pager.GetStartIndex(), pager.PageSize ); totalItemCount = results.Item1; searchResults = results.Item2.Select(x => new ReportedPostEntry { IsChecked = false, ReportedPostRecordViewModel = x }); //sanitize the user input html -- not required since its not html input /* foreach (var row in searchResults) { row.ReportedPostRecordViewModel.Note = HtmlSanitizer.sanitizer(row.ReportedPostRecordViewModel.Note).html; row.ReportedPostRecordViewModel.ReasonReported = HtmlSanitizer.sanitizer(row.ReportedPostRecordViewModel.ReasonReported).html; } * */ model.SearchResults = searchResults; } model.Pager = Shape.Pager(pager).TotalItemCount(totalItemCount); // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation. return View((object)model); }
public ActionResult Index(BindingIndexOptions options, PagerParameters pagerParameters) { if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list bindings"))) return new HttpUnauthorizedResult(); var pager = new Pager(Services.WorkContext.CurrentSite, pagerParameters); // default options if (options == null) options = new BindingIndexOptions(); var bindings = _repository.Table; switch (options.Filter) { case BindingsFilter.All: break; default: throw new ArgumentOutOfRangeException(); } if (!String.IsNullOrWhiteSpace(options.Search)) { bindings = bindings.Where(r => r.DisplayName.Contains(options.Search)); } var pagerShape = Shape.Pager(pager).TotalItemCount(bindings.Count()); switch (options.Order) { case BindingsOrder.Name: bindings = bindings.OrderBy(u => u.DisplayName); break; } var results = bindings .Skip(pager.GetStartIndex()) .Take(pager.PageSize) .ToList(); var model = new BindingIndexViewModel { Bindings = results.Select(x => new BindingEntry { Binding = x }).ToList(), Options = options, Pager = pagerShape }; // maintain previous route data when generating page links var routeData = new RouteData(); routeData.Values.Add("Options.Filter", options.Filter); routeData.Values.Add("Options.Search", options.Search); routeData.Values.Add("Options.Order", options.Order); pagerShape.RouteData(routeData); return View(model); }
public ActionResult List(PagerParameters pagerParameters) { var pager = new Pager(_services.WorkContext.CurrentSite, pagerParameters); var jobsCount = _jobsQueueManager.GetJobsCount(); var jobs = _jobsQueueManager.GetJobs(pager.GetStartIndex(), pager.PageSize).ToList(); var model = _services.New.ViewModel() .Pager(_services.New.Pager(pager).TotalItemCount(jobsCount)) .JobsQueueStatus(_services.WorkContext.CurrentSite.As<JobsQueueSettingsPart>().Status) .Jobs(jobs) ; return View(model); }
// GET: Admin public ActionResult Index(PagerParameters pagerParameters, int? filterCurrencyId = null) { var campaigns = _campaignService.GetAllCampaigns(). Where(c => (null == filterCurrencyId) || (c.CurrencyRecord.Id == filterCurrencyId)); var yesterday = DateTime.UtcNow.AddDays(-1); var last24hoursOrders = _orderService.GetAllOrders().Where(o => o.IsActive && o.Created >= yesterday && o.OrderStatusRecord.Name != OrderStatus.Cancelled.ToString() && o.OrderStatusRecord.Name != OrderStatus.Unapproved.ToString()); var featuredCampaigns = new FeaturedCampaignViewModel[] { }; var total =_campaignService.GetAllCampaigns().Count(); var totalNotApproved = _campaignService.GetAllCampaigns().Where(c => c.IsApproved == false && c.Rejected == false).Count(); if (total > 0) { featuredCampaigns = campaigns .Select(c => new CampaignViewModel { Id = c.Id, Goal = c.ProductCountGoal, Sold = c.ProductCountSold, IsFeatured = c.IsFeatured, Title = c.Title, IsActive = c.IsActive, Alias = c.Alias, CreatedDate = c.StartDate.ToLocalTime(), IsApproved = c.IsApproved, Minimum = c.ProductMinimumGoal, Rejected = c.Rejected, Currency = c.CurrencyRecord, FilterCurrencyId = filterCurrencyId }) .Select(c => new FeaturedCampaignViewModel { Campaign = c, Last24HoursSold = last24hoursOrders .SelectMany(o => o.Products) .Where(p => p.CampaignProductRecord.CampaignRecord_Id == c.Id) .Sum(p => (int?)p.Count) ?? 0 }) .OrderBy(c => c.Campaign.Id) .ToArray(); campaigns.OrderByDescending(c => c.Id); } return View("Index", new AdminFeaturedCampaignsViewModel { Campaigns = featuredCampaigns,NotApprovedTotal= totalNotApproved, Currencies = _currencyRepository}); }
public ActionResult Display(string path, PagerParameters pagerParameters) { var matchedPath = _containersPathConstraint.FindPath(path); if (string.IsNullOrEmpty(matchedPath)) { throw new ApplicationException("404 - should not have passed path constraint"); } var hits = _contentManager .Query<RoutePart, RoutePartRecord>(VersionOptions.Published) .Where(r => r.Path == matchedPath) .Slice(0, 2); if (hits.Count() == 0) { throw new ApplicationException("404 - should not have passed path constraint"); } if (hits.Count() != 1) { throw new ApplicationException("Ambiguous content"); } var container = _contentManager.Get(hits.Single().Id); IContentQuery<ContentItem> query = _contentManager .Query(VersionOptions.Published) .Join<CommonPartRecord>().Where(cr => cr.Container.Id == container.Id); var descendingOrder = container.As<ContainerPart>().Record.OrderByDirection == (int) OrderByDirection.Descending; query = query.OrderBy(container.As<ContainerPart>().Record.OrderByProperty, descendingOrder); _feedManager.Register(container.As<RoutePart>().Title, "rss", new RouteValueDictionary { { "containerid", container.Id } }); Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); pager.PageSize = pagerParameters.PageSize != null && container.As<ContainerPart>().Record.Paginated ? pager.PageSize : container.As<ContainerPart>().Record.PageSize; var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count()); var startIndex = container.As<ContainerPart>().Record.Paginated ? pager.GetStartIndex() : 0; var pageOfItems = query.Slice(startIndex, pager.PageSize).ToList(); var list = Shape.List(); list.AddRange(pageOfItems.Select(item => _contentManager.BuildDisplay(item, "Summary"))); list.Classes.Add("content-items"); list.Classes.Add("list-items"); var model = _contentManager.BuildDisplay(container, "Detail"); model.Content.Add(list, "7"); if (container.As<ContainerPart>().Record.Paginated) { model.Content.Add(pagerShape, "7.5"); } return new ShapeResult(this, model); }
public ActionResult Index(PagerParameters pagerParameters, PayoutsViewModel adminViewModel, string filter = "") { var payouts = _payoutService.GetAllPayouts(); List<History> list; if (payouts != null) { if (filter == "1") list = payouts.Select(s => new History { Id = s.Id, Date = s.Date, Event = s.Event, Amount = s.Amount, IsPlus = s.IsPlus, UserId = s.UserId, Status = s.Status }).Where(s => s.Status == "Pending" && s.IsPlus == true).ToList(); else if (filter == "2") list = payouts.Select(s => new History { Id = s.Id, Date = s.Date, Event = s.Event, Amount = s.Amount, IsPlus = s.IsPlus, UserId = s.UserId, Status = s.Status }).Where(s => s.Status == "Completed" && s.IsPlus == true).ToList(); else list = payouts.Select(s => new History { Id = s.Id, Date = s.Date, Event = s.Event, Amount = s.Amount, IsPlus = s.IsPlus, UserId = s.UserId, Status = s.Status }).Where(s => s.IsPlus == true).ToList(); var entriesProjection = list.Select(e => { return Shape.FaqEntry( Date: e.Date, Id: e.Id, Event: e.Event, Amount: e.Amount, UserId: e.UserId, IsPlus: e.IsPlus, CampaignAlias: _campService.GetCampaignByAlias(e.Event.Substring(0, (e.Event.IndexOf(" ") < 0 ? 1 : e.Event.IndexOf(" ")))) != null ? _campService.GetCampaignByAlias(e.Event.Substring(0, e.Event.IndexOf(" "))).Alias : string.Empty, CampaignName: _campService.GetCampaignByAlias(e.Event.Substring(0, (e.Event.IndexOf(" ") < 0 ? 1 : e.Event.IndexOf(" ")))) != null ? _campService.GetCampaignByAlias(e.Event.Substring(0, e.Event.IndexOf(" "))).Title : string.Empty, CampaignId: _campService.GetCampaignByAlias(e.Event.Substring(0, (e.Event.IndexOf(" ") < 0 ? 1 : e.Event.IndexOf(" ")))) != null ? _campService.GetCampaignByAlias(e.Event.Substring(0, e.Event.IndexOf(" "))).Id : 0, SellerEmail: _contentManager.Query<UserPart, UserPartRecord>().List().FirstOrDefault(user => user.Id == e.UserId) != null ? _contentManager.Query<UserPart, UserPartRecord>().List().FirstOrDefault(user => user.Id == e.UserId).Email : string.Empty ); }); //foreach(var tranz in entriesProjection){ // string alias = tranz.Event.Substring(0, tranz.Event.IndexOf(" ")); // var camp = _campService.GetCampaignByAlias(alias); // var usr = _contentManager.Query<UserPart, UserPartRecord>().List().FirstOrDefault(user => user.Id == tranz.UserId); // tranz.Event = tranz.Event.Substring(tranz.Event.IndexOf(" "), tranz.Event.Length - alias.Length); // tranz.CampaignAlias = camp.Alias; // tranz.CampaignName = camp.Title; // tranz.CampaignId = camp.Id; // tranz.SellerEmail = usr.Email; //} var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize); var entries = entriesProjection.Skip(pager.GetStartIndex()).Take(pager.PageSize); var pagerShape = Shape.Pager(pager).TotalItemCount(entriesProjection.Count()); return View("Index", new PayoutsViewModel { Transacts = entries.ToArray(), Pager = pagerShape }); } return View("Index", new PayoutsViewModel { Transacts = null, Pager = null }); }
/* public ActionResult List() { var forums = _forumService.Get().Select(fbc => _orchardServices.ContentManager.BuildDisplay(fbc, "Summary")); var list = Shape.List(); list.AddRange(forums); dynamic viewModel = Shape.ViewModel() .ContentItems(list); return View((object)viewModel); } * */ /// <summary> /// Gets a list of threads found in the specified forum /// </summary> /// <param name="forumId"></param> /// <param name="pagerParameters"></param> /// <returns></returns> public ActionResult Item( int forumId, PagerParameters pagerParameters) { var forumPart = _forumService.Get(forumId, VersionOptions.Published); if (forumPart == null) return HttpNotFound(); if (!_orchardServices.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent, forumPart, T("Not allowed to view forum"))) return new HttpUnauthorizedResult(); Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); ForumsHomePagePart forumsHomePagePart = forumPart.ForumCategoryPart.ForumsHomePagePart; int forumsHomePageId = forumsHomePagePart.Id; var showInappropriate = _orchardServices.Authorizer.Authorize(NGM.Forum.Permissions.ManageForums, forumsHomePagePart) || _orchardServices.Authorizer.Authorize(NGM.Forum.Permissions.ManageOwnForums, forumsHomePagePart) || _orchardServices.Authorizer.Authorize(NGM.Forum.Permissions.ModerateInappropriatePosts, forumsHomePagePart) || _orchardServices.Authorizer.Authorize(NGM.Forum.Permissions.ModerateOwnInappropriatePosts, forumsHomePagePart); var threadList = _threadService.Get(forumPart, pager.GetStartIndex(), pager.PageSize, showInappropriate, VersionOptions.Published); int? userId = null; if (_orchardServices.WorkContext.CurrentUser != null) { userId = _orchardServices.WorkContext.CurrentUser.Id; } //get the read state of each thread part to be displayed if (userId != null) { _threadLastReadService.SetThreadsReadState(userId.Value, forumsHomePageId, threadList); } var threads = threadList.Select(b => _orchardServices.ContentManager.BuildDisplay(b, "Summary")); dynamic forum = _orchardServices.ContentManager.BuildDisplay(forumPart); var list = Shape.List(); list.AddRange(threads); forum.Content.Add(Shape.Parts_Forums_Thread_List(ContentPart: forumPart, ContentItems: list), "5"); var totalItemCount = forumPart.ThreadCount; forum.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after"); forum.NavBar.Add(Shape.Parts_Forum_Search(ForumsHomeId: forumsHomePageId), "1"); forum.Actions.Add(Shape.Parts_Thread_ReadLegend(ForumsHomePage: forumsHomePagePart.ContentItem), "2"); return new ShapeResult(this, forum); }