public List <CPAOffer> AdjustActiveOffers(List <CPAOffer> IncomeList, bool IncludeCategory = false) { ActiveDailyOffersCount = ActiveNonDailyOffersCount = ActiveDesktopOffersCount = ActiveMobileOffersCount = 0; var resultList = new List <CPAOffer>(); //1. Seachbox if (!string.IsNullOrWhiteSpace(SearchBox1.Text)) { string patttern = SearchBox1.Text.ToLower(); foreach (var elem in IncomeList) { if (elem.Title.ToLower().Contains(patttern) || elem.Description.ToLower().Contains(patttern)) { resultList.Add(elem); } } } else { resultList = IncomeList; } //2. Category if (CategoriesList.SelectedIndex != -1 && IncludeCategory && CategoriesList.SelectedValue != "ALL") { int selected = Convert.ToInt32(CategoriesList.SelectedValue); CPACategory cat = new CPACategory(selected); var newlist = new List <CPAOffer>(); foreach (var elem in resultList) { if (elem.Category.Id == cat.Id) { newlist.Add(elem); } } resultList = newlist; } if (TitanFeatures.IsBobbyDonev) { resultList.Sort(LevelComparison); } //3. Sorting if (SortBy1.SelectedIndex != -1 && SortBy1.SelectedValue != "NONE") { if (SortBy1.SelectedValue == "ARating") { resultList.Sort(RatingComparison); } else if (SortBy1.SelectedValue == "ALast") { resultList.Sort(LastCreditedComparison); } else if (SortBy1.SelectedValue == "ADate") { resultList.Sort(DateAddedComparison); } else if (SortBy1.SelectedValue == "ATimes") { resultList.Sort(CompletedTimesComparison); } else if (SortBy1.SelectedValue == "AMoney") { resultList.Sort(MoneyEarnedComparison); } else if (SortBy1.SelectedValue == "DRating") { resultList.Sort(DRatingComparison); } else if (SortBy1.SelectedValue == "DLast") { resultList.Sort(DLastCreditedComparison); } else if (SortBy1.SelectedValue == "DDate") { resultList.Sort(DDateAddedComparison); } else if (SortBy1.SelectedValue == "DTimes") { resultList.Sort(DCompletedTimesComparison); } else if (SortBy1.SelectedValue == "DMoney") { resultList.Sort(DMoneyEarnedComparison); } } //4. Device Type if (AppSettings.CPAGPT.DeviceTypeDistinctionEnabled) { var temporaryList1 = new List <CPAOffer>(); foreach (var elem in resultList) { if (elem.DeviceType == OffersDeviceType) { temporaryList1.Add(elem); } if (elem.DeviceType == DeviceType.Desktop) { ActiveDesktopOffersCount++; } else if (elem.DeviceType == DeviceType.Mobile) { ActiveMobileOffersCount++; } } resultList = temporaryList1; } //5. Daily/Not-daily foreach (var elem in resultList) { if (elem.IsDaily) { ActiveDailyOffersCount++; } else { ActiveNonDailyOffersCount++; } } if (AppSettings.CPAGPT.DailyNotDailyButtonsEnabled) { var temporaryList2 = new List <CPAOffer>(); foreach (var elem in resultList) { if (TitanFeatures.IsBobbyDonev) { temporaryList2.Add(elem); } else if (IsDailyCategoryList && elem.IsDaily || !IsDailyCategoryList && !elem.IsDaily) { temporaryList2.Add(elem); } } resultList = temporaryList2; } //Calculate active categories count (not filtering in any way) CategoriesCount = new Dictionary <int, int>(); foreach (var offer in resultList) { if (CategoriesCount.ContainsKey(offer.IntCategory)) { CategoriesCount[offer.IntCategory]++; } else { CategoriesCount.Add(offer.IntCategory, 1); } } //6. Paging int numberOfObjectsPerPage = Convert.ToInt32(PagingDropDownList.SelectedValue); int pageNumber = CurrentPageNumber; LastPageNumber = ((resultList.Count - 1) / numberOfObjectsPerPage); NextPageButton.Visible = CurrentPageNumber < LastPageNumber; return(resultList .Skip(numberOfObjectsPerPage * pageNumber) .Take(numberOfObjectsPerPage) .ToList()); }
public static string GetText(CPACategory Category) { return(Category.Name); }