protected void Page_Load(object sender, System.EventArgs e) { _categoryId = AbleCommerce.Code.PageHelper.GetCategoryId(); _manufacturerId = AlwaysConvert.ToInt(Request.QueryString["m"]); _shopBy = StringHelper.StripHtml(Server.UrlDecode(Request.QueryString["shopby"])); if (!string.IsNullOrEmpty(_shopBy)) { _shopBy = StringHelper.StripHtml(_shopBy).Trim(); } string eventTarget = Request["__EVENTTARGET"]; if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("PageSizeOptions")) { string pageSizeOption = Request.QueryString["ps"]; if (!string.IsNullOrEmpty(pageSizeOption)) { PageSizeOptions.ClearSelection(); ListItem item = PageSizeOptions.Items.FindByValue(pageSizeOption); if (item != null) { item.Selected = true; } } } else if (eventTarget.EndsWith("PageSizeOptions")) { string url = Request.RawUrl; if (url.Contains("?")) { url = Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?")); } url += "?s=" + SortResults.SelectedValue; url += "&ps=" + PageSizeOptions.SelectedValue; if (_categoryId != 0) { url += "&c=" + _categoryId.ToString(); } if (_manufacturerId != 0) { url += "&m=" + _manufacturerId.ToString(); } if (!string.IsNullOrEmpty(_shopBy)) { url += "&shopby=" + _shopBy; } Response.Redirect(url); } int manufecturerCount = ManufacturerDataSource.CountAll(); foreach (ListItem li in SortResults.Items) { if (li.Value.StartsWith("Manufacturer")) { li.Enabled = manufecturerCount > 0; } } }
public override void OnSelectedPrinterChanged(PrintQueue printQueue) { if (printQueue.Name.Contains("Microsoft Print to PDF")) { List <string> j = PageSizeOptions.Select(c => c.PageSizeName).ToList(); if (!(j.Contains("Ansi B"))) { PageSizeOptions.Add(new Syncfusion.Windows.Controls.Printing.PrintPageSize() { PageSizeName = "Ansi B", Size = new Size(1055, 1632) }); } if (!(j.Contains("Ansi C"))) { PageSizeOptions.Add(new Syncfusion.Windows.Controls.Printing.PrintPageSize() { PageSizeName = "Ansi C", Size = new Size(1632, 2112) }); } if (!(j.Contains("Ansi D"))) { PageSizeOptions.Add(new Syncfusion.Windows.Controls.Printing.PrintPageSize() { PageSizeName = "Ansi D", Size = new Size(2112, 3264) }); } if (!(j.Contains("A0"))) { PageSizeOptions.Add(new Syncfusion.Windows.Controls.Printing.PrintPageSize() { PageSizeName = "A0", Size = new Size(3179, 4494) }); } } }
/// <summary> /// Sets page size dropdown list according to PageSize property. /// </summary> private void SetPageSize(bool forceReload) { if ((pagerElem.PageSizeDropdown.Items.Count == 0) || forceReload) { pagerElem.PageSizeDropdown.Items.Clear(); string[] sizes = PageSizeOptions.Split(','); if (sizes.Length > 0) { List <int> sizesInt = new List <int>(); // Indicates if contains 'Select ALL' macro bool containsAll = false; foreach (string size in sizes) { if (size.ToUpper() == "##ALL##") { containsAll = true; } else { sizesInt.Add(ValidationHelper.GetInteger(size.Trim(), 0)); } } // Add default page size if not pressents if ((DefaultPageSize > 0) && !sizesInt.Contains(DefaultPageSize)) { sizesInt.Add(DefaultPageSize); } // Sort list of page sizes sizesInt.Sort(); ListItem item = null; foreach (int size in sizesInt) { // Skip zero values if (size != 0) { item = new ListItem(size.ToString()); if (item.Value == DefaultPageSize.ToString()) { item.Selected = true; } pagerElem.PageSizeDropdown.Items.Add(item); } } // Add 'Select ALL' macro at the end of list if (containsAll) { item = new ListItem(GetString("general.selectall"), "-1"); if (DefaultPageSize == -1) { item.Selected = true; } pagerElem.PageSizeDropdown.Items.Add(item); } } } }
private int GetPageSizeFromPageSizeText(string text) { MatPageSizeOption?sizeOption = PageSizeOptions.FirstOrDefault(option => option.Text == text); return(sizeOption is not null ? sizeOption.Value : int.Parse(text)); }
private void GetPageSizes(Boolean init) { for (int i = 1; i < 6; i++) { PageSizeOptions.Add(i * 10); } if (init) { PageSize = PageSizeOptions.First(); } }
public void OnNavigatedTo(NavigationParameters parameters) { GetCurrentUserLocation(); if (Distance == 0) { Distance = DistanceOptions.First(); } if (PageSize == 0) { PageSize = PageSizeOptions.First(); } }
public override async void OnNavigatedTo(object navigationParameter, Windows.UI.Xaml.Navigation.NavigationMode navigationMode, Dictionary <string, object> viewModelState) { Geolocator locator = new Geolocator(); Position = await locator.GetGeopositionAsync(); if (Distance == 0) { Distance = DistanceOptions.First(); } if (PageSize == 0) { PageSize = PageSizeOptions.First(); } }
/// <summary> /// Creates a new instance of <see cref="SettingsDialogViewModel"/>. /// </summary> public SettingsDialogViewModel() { FormatOptions = Enum.GetValues(typeof(FormatTypes)).Cast <FormatTypes>().ToList(); PageSizeOptions = Enum.GetValues(typeof(PageSize)).Cast <PageSize>().ToList(); PageSizeOptions.Remove(PageSize.Undefined); ColorOptions = Enum.GetValues(typeof(XKnownColor)).Cast <XKnownColor>().ToList(); LineSizeOptions = Enum.GetValues(typeof(CutLineSizes)).Cast <CutLineSizes>().ToList(); PdfSaveFolder = Settings.Default.PdfSaveFolder; PdfJpegQuality = Settings.Default.PdfJpegQuality; PdfHasCutLines = Settings.Default.PdfHasCutLines; CutLineColor = Settings.Default.CutLineColor; CutLineSize = Settings.Default.CutLineSize; PdfScalingPercent = Settings.Default.PdfScalingPercent; PdfOpenWhenSaveDone = Settings.Default.PdfOpenWhenSaveDone; PdfPageSize = Settings.Default.PdfPageSize; SelectedFormat = Settings.Default.SavedFormat; MaxPrice = Settings.Default.MaxPrice; }
protected void Page_Load(object sender, EventArgs e) { string eventTarget = Request["__EVENTTARGET"]; if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("PageSizeOptions")) { string pageSizeOption = Request.QueryString["ps"]; if (!string.IsNullOrEmpty(pageSizeOption)) { PageSizeOptions.ClearSelection(); ListItem item = PageSizeOptions.Items.FindByValue(pageSizeOption); if (item != null) { item.Selected = true; } } } else if (eventTarget.EndsWith("PageSizeOptions")) { string url = Request.RawUrl; if (url.Contains("?")) { url = Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?")); } url += "?s=" + SortResults.SelectedValue; url += "&ps=" + PageSizeOptions.SelectedValue; Response.Redirect(url); } _pageSize = AlwaysConvert.ToInt(PageSizeOptions.SelectedValue); CatalogNodeList.RepeatColumns = Cols; if (IsValidCategory()) { // INITIALIZE THE CONTENT NODES _contentNodes = new List <CatalogNode>(); IList <CatalogNode> visibleNodes; if (_category != null) { visibleNodes = CatalogDataSource.LoadForCategory(_category.Id, true, true, 0, 0, string.Empty); } else { visibleNodes = CatalogDataSource.LoadForCategory(0, true, true, 0, 0, string.Empty); } if (visibleNodes.Count > 0) { // FETCH THE ASSOCIATED CATALOG ITEMS INTO ORM OBJECT GRAPH AND DISCARD RESULTS // THIS IS ESSENTIALLY FOR PERFORMANCE BOOST BY MINIMIZING NUMBER OF QUERIES var productIds = visibleNodes.Where(n => n.CatalogNodeType == CatalogNodeType.Product) .Select(n => n.CatalogNodeId) .ToList <int>(); if (productIds.Count > 0 && productIds.Count < 415) { var futureQuery = NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(productIds) .Fetch(p => p.Specials).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(productIds) .Fetch(p => p.ProductOptions).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(productIds) .Fetch(p => p.ProductKitComponents).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(productIds) .Fetch(p => p.ProductTemplates).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(productIds) .Fetch(p => p.Reviews).Eager .Future <Product>(); futureQuery.ToList(); } var categoryIds = visibleNodes.Where(n => n.CatalogNodeType == CatalogNodeType.Category) .Select(n => n.CatalogNodeId) .ToList <int>(); if (categoryIds.Count > 0 && categoryIds.Count < 2000) { NHibernateHelper.QueryOver <Category>() .AndRestrictionOn(c => c.Id).IsIn(categoryIds) .List <Category>(); } var webpageIds = visibleNodes.Where(n => n.CatalogNodeType == CatalogNodeType.Webpage) .Select(n => n.CatalogNodeId) .ToList <int>(); if (webpageIds.Count > 0 && webpageIds.Count < 2000) { NHibernateHelper.QueryOver <Webpage>() .AndRestrictionOn(w => w.Id).IsIn(webpageIds) .List <Webpage>(); } var linkIds = visibleNodes.Where(n => n.CatalogNodeType == CatalogNodeType.Link) .Select(n => n.CatalogNodeId) .ToList <int>(); if (linkIds.Count > 0 && linkIds.Count < 2000) { NHibernateHelper.QueryOver <Link>() .AndRestrictionOn(l => l.Id).IsIn(linkIds) .List <Link>(); } } foreach (CatalogNode node in visibleNodes) { if (node.CatalogNodeType == CatalogNodeType.Category) { // only add categories that have publicly visible content int visibleCount = CatalogDataSource.CountForCategory(node.CatalogNodeId, true, true); if (visibleCount > 0) { _contentNodes.Add(node); } } else { _contentNodes.Add(node); } } if (_pageSize == 0) { _pageSize = _contentNodes.Count; } int minimumPageSize = AlwaysConvert.ToInt(PageSizeOptions.Items[0].Value); PageSizePanel.Visible = _contentNodes.Count > minimumPageSize; // BIND PAGE BindPage(); } int manufecturerCount = ManufacturerDataSource.CountAll(); foreach (ListItem li in SortResults.Items) { if (li.Value.StartsWith("Manufacturer")) { li.Enabled = manufecturerCount > 0; } } }
public void ChangePageSize(int pageSize) { PageSize = pageSize; PageSizeOptions.Clear(); PageSizeOptions.Add(new MatPageSizeOption(PageSize)); }
protected void Page_Load(object sender, EventArgs e) { // SET THE DEFAULT PAGE SIZE AND ADD A NEW OPTION BASED ON MaxItems parameter value if needed if (!Page.IsPostBack) { CategoryBreadCrumbs1.Visible = this.DisplayBreadCrumbs; } InitializePageSize(); if (IsValidCategory()) { string eventTarget = Request["__EVENTTARGET"]; if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("PageSizeOptions")) { PageSizeOptions.ClearSelection(); ListItem item = PageSizeOptions.Items.FindByValue(_pageSize.ToString()); if (item != null) { item.Selected = true; } } if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("SortResults")) { string sortOption = Request.QueryString["s"]; if (!string.IsNullOrEmpty(sortOption)) { SortResults.ClearSelection(); ListItem item = SortResults.Items.OfType <ListItem>().FirstOrDefault(x => string.Compare(x.Value, sortOption, StringComparison.InvariantCultureIgnoreCase) == 0); if (item != null) { item.Selected = true; } } } if (!string.IsNullOrEmpty(eventTarget)) { if (eventTarget.EndsWith("PageSizeOptions") || eventTarget.EndsWith("SortResults")) { string url = Request.RawUrl; if (url.Contains("?")) { url = Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?")); } url += "?s=" + SortResults.SelectedValue; url += "&ps=" + _pageSize.ToString(); Response.Redirect(url); } } Caption.Text = this.DefaultCaption; if (_Category != null) { // use category name if no default name is specified if (string.IsNullOrEmpty(Caption.Text)) { Caption.Text = _Category.Name; } CategoryBreadCrumbs1.CategoryId = this.CategoryId; if (!string.IsNullOrEmpty(_Category.Summary) && ShowSummary) { CategorySummary.Text = _Category.Summary; } if (!string.IsNullOrEmpty(_Category.Description) && ShowDescription) { CategoryDescriptionPanel.Visible = true; CategoryDescription.Text = _Category.Description; } else { CategoryDescriptionPanel.Visible = false; } } else { // IT IS ROOT CATEGORY CategoryBreadCrumbs1.CategoryId = this.CategoryId; if (ShowSummary) { CategorySummary.Text = DefaultCategorySummary; } } if (_Category != null) { int count = WebpageDataSource.CountForCategory(_Category.Id, true, true); if (count > 0) { _currentPageIndex = AlwaysConvert.ToInt(Request.QueryString["p"]); if (_pageSize == 0) { _lastPageIndex = 0; } else { _lastPageIndex = ((int)Math.Ceiling(((double)count / (double)_pageSize))) - 1; } CatalogNodeList.DataSource = WebpageDataSource.LoadForCategory(_Category.Id, true, true, SortResults.SelectedValue, _pageSize, (_currentPageIndex * _pageSize)); CatalogNodeList.DataBind(); int startRowIndex = (_pageSize * _currentPageIndex); int endRowIndex = startRowIndex + _pageSize; if (endRowIndex > count || endRowIndex == 0) { endRowIndex = count; } if (count == 0) { startRowIndex = -1; } ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, (startRowIndex + 1), endRowIndex, count); ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, (startRowIndex + 1), endRowIndex, count); BindPagingControls(); } else { phEmptyCategory.Visible = true; } AbleCommerce.Code.PageVisitHelper.RegisterPageVisit(_Category.Id, CatalogNodeType.Category, _Category.Name); } } }
protected void Page_Load(object sender, System.EventArgs e) { Trace.Write(this.GetType().ToString(), "Load Begin"); _categoryId = AbleCommerce.Code.PageHelper.GetCategoryId(); _manufacturerId = AlwaysConvert.ToInt(Request.QueryString["m"]); _keywords = Server.UrlDecode(Request.QueryString["k"]); _shopBy = StringHelper.StripHtml(Server.UrlDecode(Request.QueryString["shopby"])); if (!string.IsNullOrEmpty(_shopBy)) { _shopBy = StringHelper.StripHtml(_shopBy).Trim(); } string eventTarget = Request["__EVENTTARGET"]; if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("PageSizeOptions")) { string pageSizeOption = Request.QueryString["ps"]; if (!string.IsNullOrEmpty(pageSizeOption)) { PageSizeOptions.ClearSelection(); ListItem item = PageSizeOptions.Items.FindByValue(pageSizeOption); if (item != null) { item.Selected = true; } } } else if (eventTarget.EndsWith("PageSizeOptions")) { string url = Request.RawUrl; if (url.Contains("?")) { url = Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?")); } url += "?s=" + SortResults.SelectedValue; url += "&ps=" + PageSizeOptions.SelectedValue; if (_categoryId != 0) { url += "&c=" + _categoryId.ToString(); } if (_manufacturerId != 0) { url += "&m=" + _manufacturerId.ToString(); } if (!string.IsNullOrEmpty(_shopBy)) { url += "&shopby=" + _shopBy; } Response.Redirect(url); } _pageSize = AlwaysConvert.ToInt(PageSizeOptions.SelectedValue); ProductList.RepeatColumns = Cols; if (!string.IsNullOrEmpty(_keywords)) { _keywords = StringHelper.StripHtml(_keywords).Trim(); } _category = CategoryDataSource.Load(this._categoryId); if (_pageSize == 0) { _pageSize = ProductDataSource.AdvancedSearchCount(_keywords, _categoryId, _manufacturerId, true, true, true, 0, 0, false, PageHelper.GetShopByChoices()); } //EXIT PROCESSING IF CATEGORY IS INVALID OR MARKED PRIVATE if (!IsValidCategory()) { SearchResultsAjaxPanel.Visible = false; } else { if (_category != null) { //REGISTER THE PAGEVISIT AbleCommerce.Code.PageVisitHelper.RegisterPageVisit(_category.Id, CatalogNodeType.Category, _category.Name); } if (!Page.IsPostBack) { //INITIALIZE SEARCH CRITERIA ON FIRST VISIT HiddenPageIndex.Value = Request.QueryString["p"]; string tempSort = Request.QueryString["s"]; if (!string.IsNullOrEmpty(tempSort)) { ListItem item = SortResults.Items.OfType <ListItem>().SingleOrDefault(x => string.Compare(x.Value, tempSort, StringComparison.InvariantCultureIgnoreCase) == 0); if (item != null) { item.Selected = true; } } } } // NEED TO BIND THE PAGE // BUT IF THE MULTIPLE ADD TO BASKET BUTTON CLICKED THEN THE BINDING SHOULD TAKE PLACE AT PRE_RENDER // THAT IS AFTER ADD TO CART if (IsValidCategory() && Request.Form["__EVENTTARGET"] != MultipleAddToBasketButton.UniqueID) { BindPage(); MultipleAddToBasketButton.Visible = _quantityVisible; } int manufecturerCount = ManufacturerDataSource.CountAll(); foreach (ListItem li in SortResults.Items) { if (li.Value.StartsWith("Manufacturer")) { li.Enabled = manufecturerCount > 0; } } }
protected void Page_Load(object sender, System.EventArgs e) { _categoryId = AlwaysConvert.ToInt(Request.QueryString["c"]); _manufacturerId = AlwaysConvert.ToInt(Request.QueryString["m"]); _keywords = StringHelper.StripHtml(Server.UrlDecode(Request.QueryString["k"])); if (!string.IsNullOrEmpty(_keywords)) { _keywords = StringHelper.StripHtml(_keywords).Trim(); } _shopBy = StringHelper.StripHtml(Server.UrlDecode(Request.QueryString["shopby"])); if (!string.IsNullOrEmpty(_shopBy)) { _shopBy = StringHelper.StripHtml(_shopBy).Trim(); } string eventTarget = Request["__EVENTTARGET"]; if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("PageSizeOptions")) { string pageSizeOption = Request.QueryString["ps"]; if (!string.IsNullOrEmpty(pageSizeOption)) { PageSizeOptions.ClearSelection(); ListItem item = PageSizeOptions.Items.FindByValue(pageSizeOption); if (item != null) { item.Selected = true; } } } else if (eventTarget.EndsWith("PageSizeOptions")) { string url = Request.RawUrl; if (url.Contains("?")) { url = Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?")); } url += "?s=" + SortResults.SelectedValue; url += "&ps=" + PageSizeOptions.SelectedValue; if (_categoryId != 0) { url += "&c=" + _categoryId.ToString(); } if (_manufacturerId != 0) { url += "&m=" + _manufacturerId.ToString(); } if (!string.IsNullOrEmpty(_keywords)) { url += "&k=" + _keywords; } if (!string.IsNullOrEmpty(_shopBy)) { url += "&shopby=" + _shopBy; } Response.Redirect(url); } _pageSize = AlwaysConvert.ToInt(PageSizeOptions.SelectedValue); ProductList.RepeatColumns = Cols; if (_pageSize == 0) { _pageSize = ProductDataSource.AdvancedSearchCount(_keywords, _categoryId, _manufacturerId, true, true, true, 0, 0, false, PageHelper.GetShopByChoices()); } if (!Page.IsPostBack) { if (ApplicationSettings.Instance.SearchProvider == "LuceneSearchProvider" || ApplicationSettings.Instance.SearchProvider == "SqlFtsSearchProvider") { bool sortByRelevance = true; if (!string.IsNullOrEmpty(_keywords)) { ISearchProvider provider = SearchProviderLocator.Locate(); LuceneSearchProvider lucene = provider as LuceneSearchProvider; if (lucene != null) { sortByRelevance = !lucene.UseSQLSearch(_keywords); } SqlFtsSearchProvider sqlFTS = provider as SqlFtsSearchProvider; if (sqlFTS != null) { sortByRelevance = !sqlFTS.UseSQLSearch(_keywords); } } if (sortByRelevance) { SortResults.Items.Insert(0, new ListItem("By Relevance", "FTS.RANK DESC")); } } //INITIALIZE SEARCH CRITERIA ON FIRST VISIT HiddenPageIndex.Value = AlwaysConvert.ToInt(Request.QueryString["p"]).ToString(); string tempSort = Request.QueryString["s"]; if (!string.IsNullOrEmpty(tempSort)) { ListItem item = SortResults.Items.FindByValue(tempSort); if (item != null) { item.Selected = true; } } } int manufecturerCount = ManufacturerDataSource.CountAll(); bool showSortByManufacturer = false; if (manufecturerCount > 0 && _manufacturerId == 0) { IList <ManufacturerProductCount> mCounts = ProductDataSource.AdvancedSearchCountByManufacturer(_keywords, _categoryId, true, true, true, 0, 0, PageHelper.GetShopByChoices()); showSortByManufacturer = mCounts != null && mCounts.Count > 0; } foreach (ListItem li in SortResults.Items) { if (li.Value.StartsWith("Manufacturer")) { li.Enabled = showSortByManufacturer; } } BindSearchResultsPanel(); }
/// <summary> /// Gets the visible. /// </summary> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> protected bool GetVisible() { return(Visible && (AlwaysVisible || Count > PageSize || (PageSizeOptions != null && PageSizeOptions.Any()))); }
protected void Page_Load(object sender, EventArgs e) { string eventTarget = Request["__EVENTTARGET"]; if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("PageSizeOptions")) { string pageSizeOption = Request.QueryString["ps"]; if (!string.IsNullOrEmpty(pageSizeOption)) { PageSizeOptions.ClearSelection(); ListItem item = PageSizeOptions.Items.FindByValue(pageSizeOption); if (item != null) { item.Selected = true; } } } else if (eventTarget.EndsWith("PageSizeOptions")) { string url = Request.RawUrl; if (url.Contains("?")) { url = Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?")); } url += "?s=" + SortResults.SelectedValue; url += "&ps=" + PageSizeOptions.SelectedValue; Response.Redirect(url); } _pageSize = AlwaysConvert.ToInt(PageSizeOptions.SelectedValue); SetPagerIndex(); CatalogNodeList.RepeatColumns = Cols; if (IsValidCategory()) { //INITIALIZE THE CONTENT NODES _ContentNodes = new List <Product>(); List <Product> visibleNodes = (List <Product>)ProductDataSource.LoadForCategory(true, this.CategoryId, false, true, SortResults.SelectedValue, _pageSize, (_HiddenPageIndex * _pageSize)); // CUSTOM SORTING ON VOLUME PRICES if (SortResults.SelectedValue.Equals("Price ASC")) { visibleNodes = visibleNodes.OrderBy(x => (x.VolumeDiscounts.Any() && x.VolumeDiscounts[0].Levels.Any()) ? x.VolumeDiscounts[0].Levels.First().DiscountAmount : x.Price).ThenBy(x => (x.VolumeDiscounts.Any() && x.VolumeDiscounts[0].Levels.Any()) ? x.VolumeDiscounts[0].Levels.Last().DiscountAmount : 0).ToList(); //Lowest-Highest } else if (SortResults.SelectedValue.Equals("Price DESC")) { visibleNodes = visibleNodes.OrderByDescending(x => (x.VolumeDiscounts.Any() && x.VolumeDiscounts[0].Levels.Any()) ? x.VolumeDiscounts[0].Levels.First().DiscountAmount : x.Price).ThenByDescending(x => (x.VolumeDiscounts.Any() && x.VolumeDiscounts[0].Levels.Any()) ? x.VolumeDiscounts[0].Levels.Last().DiscountAmount : 0).ToList(); //Highest-Lowest } if (visibleNodes.Count > 0) { _ContentNodes.AddRange(visibleNodes); // DELAYED QUERIES TO EAGER LOAD RELATED DATA FOR PERFORMANCE BOOST List <int> ids = visibleNodes.Select(p => p.Id).ToList(); var futureQuery = NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.Specials).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.ProductOptions).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.ProductKitComponents).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.ProductTemplates).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.Reviews).Eager .Future <Product>(); futureQuery.ToList(); } if (_pageSize == 0) { _pageSize = _ContentNodes.Count; } int minimumPageSize = AlwaysConvert.ToInt(PageSizeOptions.Items[0].Value); PageSizePanel.Visible = _searchResultCount > minimumPageSize; //BIND PAGE BindPage(); } int manufecturerCount = ManufacturerDataSource.CountAll(); foreach (ListItem li in SortResults.Items) { if (li.Value.StartsWith("Manufacturer")) { li.Enabled = manufecturerCount > 0; } } }
public async Task <PaginatedListDto <StudentListItem> > ListAllStudentssAsync( ListingFilterSortPageDto filterSortPageDto) { // call this first to: // - reset the PageNo by comparing the previous an current listing criteria filterSortPageDto.InitDto(); var students = _context.Students .Select(s => new StudentListItem { FirstMidName = s.FirstMidName, LastName = s.LastName, EnrollmentDate = s.EnrollmentDate, StudentId = s.StudentId }); StudentsFilterOptions filterBy = (StudentsFilterOptions)filterSortPageDto.FilterBy; var filterValue = filterSortPageDto.FilterValue; if (filterBy > 0 && !String.IsNullOrWhiteSpace(filterValue)) { switch (filterBy) { case StudentsFilterOptions.FirstMidName: students = students.Where(s => (s.FirstMidName.Contains(filterValue))); break; case StudentsFilterOptions.LastName: students = students.Where(s => (s.LastName.Contains(filterValue))); break; case StudentsFilterOptions.EnrollmentDateAfter: try { DateTime filterValueDate = DateTime.ParseExact( filterValue, "yyyy-MM-dd", CultureInfo.CurrentCulture); students = students.Where(s => (s.EnrollmentDate >= filterValueDate)); } catch (Exception) { throw new GeneralException("Please enter a valid date value and retry."); } break; case StudentsFilterOptions.EnrollmentDateBefore: try { DateTime filterValueDate = DateTime.ParseExact( filterValue, "yyyy-MM-dd", CultureInfo.CurrentCulture); students = students.Where(s => (s.EnrollmentDate <= filterValueDate)); } catch (Exception) { throw new GeneralException("Please enter a valid date value and retry."); } break; } } // Order By StudentsSortByOptions sortBy = (StudentsSortByOptions)filterSortPageDto.SortBy; bool sortAscending = filterSortPageDto.SortAscending; if (sortAscending) { students = students.OrderBy(e => EF.Property <object>(e, sortBy.ToString())); } else { students = students.OrderByDescending(e => EF.Property <object>(e, sortBy.ToString())); } PageSizeOptions pageSize = (PageSizeOptions)filterSortPageDto.PageSize; var pageIndex = filterSortPageDto.PageIndex; var paginatedList = await PaginatedListHelper <StudentListItem> .CreateAsync( students.AsNoTracking(), pageIndex, (int)pageSize); return(paginatedList); }