public void DisplayData() { PhonebookDataLoading = true; PhonebookListResponse response = new PhonebookSQLiteRepository() .GetPhonebooksByPage(MainWindow.CurrentCompanyId, PhonebookSearchObject, currentPage, itemsPerPage); if (response.Success) { PhonebooksFromDB = new ObservableCollection <PhonebookViewModel>(response.Phonebooks ?? new List <PhonebookViewModel>()); totalItems = response.TotalItems; } else { PhonebooksFromDB = new ObservableCollection <PhonebookViewModel>(); 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; PhonebookDataLoading = false; }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (currentPhonebook?.Name == null) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_NazivUzvičnik")); return; } #endregion Thread td = new Thread(() => { SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SubmitButtonEnabled = false; currentPhonebook.IsSynced = false; currentPhonebook.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; currentPhonebook.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; PhonebookResponse response = new PhonebookSQLiteRepository().Create(currentPhonebook); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_čuvanjaUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; } response = PhonebookService.Create(currentPhonebook); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Podaci_su_sačuvani_u_lokaluUzvičnikTačka_Greška_kod_čuvanja_na_serveruUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; } if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; new PhonebookSQLiteRepository().Sync(PhonebookService); PhonebookCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }