public async Task <ActionResult> Index(int p = 1, int pageSize = 20, string orderBy = nameof(DirectoryInfo.LastWriteTime) + " desc", string search = "") { var cts = TaskHelper.CreateChildCancellationTokenSource(ClientDisconnectedToken()); try { var repository = _fileSystemGenericRepositoryFactory.CreateFolderRepository(cts.Token, _hostingEnvironment.MapWwwPath(AppSettings.Folders[Folders.Gallery])); var data = await repository.SearchAsync(search, null, UIHelper.GetOrderByIQueryableDelegate <DirectoryInfo>(orderBy), (p - 1) *pageSize, pageSize); var total = await repository.GetSearchCountAsync(search, null); var response = new WebApiPagedResponseDto <DirectoryInfo> { Page = p, PageSize = pageSize, Records = total, Rows = data.ToList(), OrderBy = orderBy, Search = search }; ViewBag.Search = search; ViewBag.Page = p; ViewBag.PageSize = pageSize; ViewBag.OrderBy = orderBy; return(View(response)); } catch { return(HandleReadException()); } }
public async Task <ActionResult> Index(int page = 1, int pageSize = 20, string orderColumn = nameof(DirectoryInfo.LastWriteTime), string orderType = "desc", string search = "") { var cts = TaskHelper.CreateChildCancellationTokenSource(ClientDisconnectedToken()); try { var repository = _fileSystemGenericRepositoryFactory.CreateFolderRepository(cts.Token, Server.GetWwwFolderPhysicalPathById(Folders.Gallery)); var dataTask = repository.SearchAsync(search, null, LamdaHelper.GetOrderByFunc <DirectoryInfo>(orderColumn, orderType), (page - 1) * pageSize, pageSize); var totalTask = repository.GetSearchCountAsync(search, null); await TaskHelper.WhenAllOrException(cts, dataTask, totalTask); var data = dataTask.Result; var total = totalTask.Result; var response = new WebApiPagedResponseDto <DirectoryInfo> { Page = page, PageSize = pageSize, Records = total, Rows = data.ToList(), OrderColumn = orderColumn, OrderType = orderType, Search = search }; ViewBag.Search = search; ViewBag.Page = page; ViewBag.PageSize = pageSize; ViewBag.OrderColumn = orderColumn; ViewBag.OrderType = orderType; return(View(response)); } catch { return(HandleReadException()); } }
protected async override Task <IList <SitemapNode> > GetSitemapNodes(CancellationToken cancellationToken) { IList <SitemapNode> nodes = await base.GetSitemapNodes(cancellationToken); //Locations nodes.Add( new SitemapNode() { Url = Url.AbsoluteUrl <LocationsController>(c => c.Index(1, 20, nameof(LocationDto.Name) + " asc", ""), AppSettings, false), Priority = 0.9 }); //countries nodes.Add( new SitemapNode() { Url = Url.AbsoluteUrl <CountriesController>(c => c.Index(1, 20, nameof(LocationDto.Name) + " asc", ""), AppSettings, false), Priority = 0.9 }); foreach (TagDto t in (await _blogService.TagApplicationService.GetAllAsync(cancellationToken, null, null, null))) { nodes.Add( new SitemapNode() { Url = Url.AbsoluteUrl(nameof(BlogController.Tag), "Blog", AppSettings, new { tagSlug = t.UrlSlug }), Frequency = SitemapFrequency.Weekly, Priority = 0.8 }); } foreach (CategoryDto c in (await _blogService.CategoryApplicationService.GetAsync(cancellationToken, c => c.Published, null, null))) { nodes.Add( new SitemapNode() { Url = Url.AbsoluteUrl(nameof(BlogController.Category), "Blog", AppSettings, new { categorySlug = c.UrlSlug }), Frequency = SitemapFrequency.Weekly, Priority = 0.8 }); } foreach (BlogPostDto p in (await _blogService.BlogPostApplicationService.GetPostsAsync(0, 200, cancellationToken))) { nodes.Add( new SitemapNode() { Url = Url.AbsoluteUrl <BlogController>(c => c.Post(p.CreatedOn.Year, p.CreatedOn.Month, p.UrlSlug), AppSettings), Frequency = SitemapFrequency.Weekly, Priority = 0.7 }); } var repository = _fileSystemGenericRepositoryFactory.CreateFolderRepository(cancellationToken, _hostingEnvironment.MapWwwPath(AppSettings.Folders[Folders.Gallery])); foreach (DirectoryInfo f in (await repository.GetAllAsync(UIHelper.GetOrderByIQueryableDelegate <DirectoryInfo>(nameof(DirectoryInfo.LastWriteTime) + " desc"), null, null))) { nodes.Add( new SitemapNode() { Url = Url.AbsoluteUrl("Gallery", "Gallery", AppSettings, new { name = f.Name.ToSlug() }), Frequency = SitemapFrequency.Weekly, Priority = 0.7 }); } foreach (LocationDto l in (await _locationService.GetAllAsync(cancellationToken, null, null, null))) { if (!string.IsNullOrEmpty(l.UrlSlug)) { nodes.Add( new SitemapNode() { Url = Url.AbsoluteUrl <LocationsController>(lc => lc.Location(l.UrlSlug), AppSettings), Frequency = SitemapFrequency.Weekly, Priority = 0.6 }); } } return(nodes); }