private void PopulateFromDb(string filterString = "") { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { if (CurrentCountry != null) { SectorListResponse SectorResp = new SectorSQLiteRepository().GetSectorsForPopup(MainWindow.CurrentCompanyId, CurrentCountry.Identifier, filterString); if (SectorResp.Success) { SectorsFromDB = new ObservableCollection <SectorViewModel>(SectorResp.Sectors ?? new List <SectorViewModel>()); } if (SectorsFromDB.Count == 1) { CurrentSector = SectorsFromDB.FirstOrDefault(); } else { SectorsFromDB = new ObservableCollection <SectorViewModel>(); } } else { SectorsFromDB = new ObservableCollection <SectorViewModel>(); } }) ); }
public void DisplayData() { SectorDataLoading = true; SectorListResponse response = new SectorSQLiteRepository() .GetSectorsByPage(MainWindow.CurrentCompanyId, SectorSearchObject, currentPage, itemsPerPage); if (response.Success) { SectorsFromDB = new ObservableCollection <SectorViewModel>(response.Sectors ?? new List <SectorViewModel>()); totalItems = response.TotalItems; } else { SectorsFromDB = new ObservableCollection <SectorViewModel>(); totalItems = 0; MainWindow.ErrorMessage = response.Message; } int itemFrom = totalItems != 0 ? (currentPage - 1) * itemsPerPage + 1 : 0; int itemTo = currentPage * itemsPerPage < totalItems ? currentPage * itemsPerPage : totalItems; PaginationDisplay = itemFrom + " - " + itemTo + " od " + totalItems; SectorDataLoading = false; }