private void PopulateFromDb(string filterString = "") { Thread th = new Thread(() => { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { if (CurrentRegion != null) { //new MunicipalitySQLiteRepository().Sync(municipalityService); MunicipalityListResponse municipalityResp = new MunicipalitySQLiteRepository().GetMunicipalitiesForPopup(MainWindow.CurrentCompanyId, CurrentRegion.Identifier, filterString); if (municipalityResp.Success) { MunicipalitysFromDB = new ObservableCollection <MunicipalityViewModel>(municipalityResp.Municipalities ?? new List <MunicipalityViewModel>()); } else { MunicipalitysFromDB = new ObservableCollection <MunicipalityViewModel>(); } } else { MunicipalitysFromDB = new ObservableCollection <MunicipalityViewModel>(); } })); }); th.IsBackground = true; th.Start(); }
public void DisplayData() { MunicipalityDataLoading = true; MunicipalityListResponse response = new MunicipalitySQLiteRepository() .GetMunicipalitiesByPage(MainWindow.CurrentCompanyId, MunicipalitySearchObject, currentPage, itemsPerPage); if (response.Success) { MunicipalitiesFromDB = new ObservableCollection <MunicipalityViewModel>(response.Municipalities ?? new List <MunicipalityViewModel>()); totalItems = response.TotalItems; } else { MunicipalitiesFromDB = new ObservableCollection <MunicipalityViewModel>(); 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; MunicipalityDataLoading = false; }