private void BtnDelete_Click(object sender, RoutedEventArgs e) { var response = new BusinessPartnerDocumentSQLiteRepository().SetStatusDeleted(CurrentBusinessPartnerDocumentDG.Identifier); if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik")); CurrentBusinessPartnerDocumentForm = new BusinessPartnerDocumentViewModel(); CurrentBusinessPartnerDocumentForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerDocumentForm.ItemStatus = ItemStatus.Added; CurrentBusinessPartnerDocumentDG = null; BusinessPartnerCreatedUpdated(); Thread displayThread = new Thread(() => DisplayBusinessPartnerDocumentData()); displayThread.IsBackground = true; displayThread.Start(); } else { MainWindow.ErrorMessage = response.Message; } }
private void DisplayBusinessPartnerDocumentData() { BusinessPartnerDocumentDataLoading = true; BusinessPartnerDocumentListResponse response = new BusinessPartnerDocumentSQLiteRepository() .GetFilteredBusinessPartnerDocuments(MainWindow.CurrentCompanyId, FilterBusinessPartnerDocuments); if (response.Success) { BusinessPartnerDocumentsFromDB = new ObservableCollection <BusinessPartnerDocumentViewModel>( response.BusinessPartnerDocuments ?? new List <BusinessPartnerDocumentViewModel>()); } else { BusinessPartnerDocumentsFromDB = new ObservableCollection <BusinessPartnerDocumentViewModel>(); } BusinessPartnerDocumentDataLoading = false; }
private void btnAddDocument_Click(object sender, RoutedEventArgs e) { #region Validation if (CurrentBusinessPartnerDocumentForm.Name == null) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Naziv")); return; } #endregion Thread th = new Thread(() => { SubmitButtonEnabled = false; CurrentBusinessPartnerDocumentForm.BusinessPartner = CurrentBusinessPartner; CurrentBusinessPartnerDocumentForm.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentBusinessPartnerDocumentForm.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; new BusinessPartnerDocumentSQLiteRepository().Delete(CurrentBusinessPartnerDocumentForm.Identifier); var response = new BusinessPartnerDocumentSQLiteRepository().Create(CurrentBusinessPartnerDocumentForm); if (!response.Success) { MainWindow.ErrorMessage = response.Message; CurrentBusinessPartnerDocumentForm = new BusinessPartnerDocumentViewModel(); CurrentBusinessPartnerDocumentForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerDocumentForm.ItemStatus = ItemStatus.Added; CurrentBusinessPartnerDocumentForm.IsSynced = false; return; } CurrentBusinessPartnerDocumentForm = new BusinessPartnerDocumentViewModel(); CurrentBusinessPartnerDocumentForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerDocumentForm.ItemStatus = ItemStatus.Added; CurrentBusinessPartnerDocumentForm.IsSynced = false; BusinessPartnerCreatedUpdated(); DisplayBusinessPartnerDocumentData(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtBusinessPartnerDocumentName.Focus(); }) ); SubmitButtonEnabled = true; }); th.IsBackground = true; th.Start(); }