public void DisplayData() { ShipmentDataLoading = true; ShipmentListResponse response = new ShipmentSQLiteRepository() .GetShipmentsByPage(MainWindow.CurrentCompanyId, ShipmentSearchObject, currentPage, itemsPerPage); if (response.Success) { ShipmentsFromDB = new ObservableCollection <ShipmentViewModel>(response.Shipments ?? new List <ShipmentViewModel>()); totalItems = response.TotalItems; } else { ShipmentsFromDB = new ObservableCollection <ShipmentViewModel>(); 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; ShipmentDataLoading = false; }
private void PopulateFromDb(string filterString = "") { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { new ShipmentSQLiteRepository().Sync(ShipmentService); ShipmentListResponse regionResp = new ShipmentSQLiteRepository().GetShipmentsForPopup(MainWindow.CurrentCompanyId, filterString); if (regionResp.Success) { ShipmentsFromDB = new ObservableCollection <ShipmentViewModel>(regionResp.Shipments ?? new List <ShipmentViewModel>()); } else { ShipmentsFromDB = new ObservableCollection <ShipmentViewModel>(); } }) ); }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (currentShipment?.ShipmentNumber == null) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Broj_posiljke")); return; } #endregion Thread td = new Thread(() => { SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SubmitButtonEnabled = false; currentShipment.IsSynced = false; currentShipment.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; currentShipment.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; ShipmentResponse response = new ShipmentSQLiteRepository().Create(currentShipment); 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 = ShipmentService.Create(currentShipment); 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 ShipmentSQLiteRepository().Sync(ShipmentService); ShipmentCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }