public void DisplayData() { BankDataLoading = true; BankListResponse response = new BankSQLiteRepository() .GetBanksByPage(MainWindow.CurrentCompanyId, BankSearchObject, currentPage, itemsPerPage); if (response.Success) { BanksFromDB = new ObservableCollection <BankViewModel>(response.Banks ?? new List <BankViewModel>()); totalItems = response.TotalItems; } else { BanksFromDB = new ObservableCollection <BankViewModel>(); 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; BankDataLoading = false; }
private void PopulateFromDb(string filterString = "") { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { BankListResponse Response = new BankSQLiteRepository().GetBanksForPopup(MainWindow.CurrentCompanyId, filterString); if (Response.Success) { if (Response.Banks != null && Response.Banks.Count > 0) { BanksFromDB = new ObservableCollection <BankViewModel>( Response.Banks?.ToList() ?? new List <BankViewModel>()); if (BanksFromDB.Count == 1) { CurrentBank = BanksFromDB.FirstOrDefault(); } } else { BanksFromDB = new ObservableCollection <BankViewModel>(); CurrentBank = null; } } }) ); }