private void btnAddNote_Click(object sender, RoutedEventArgs e) { #region Validation if (CurrentPhysicalPersonDocumentForm.Name == null) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Naziv")); return; } #endregion Thread th = new Thread(() => { SubmitButtonEnabled = false; CurrentPhysicalPersonDocumentForm.PhysicalPerson = CurrentPhysicalPerson; CurrentPhysicalPersonDocumentForm.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentPhysicalPersonDocumentForm.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; new PhysicalPersonDocumentSQLiteRepository().Delete(CurrentPhysicalPersonDocumentForm.Identifier); var response = new PhysicalPersonDocumentSQLiteRepository().Create(CurrentPhysicalPersonDocumentForm); if (!response.Success) { MainWindow.ErrorMessage = response.Message; CurrentPhysicalPersonDocumentForm = new PhysicalPersonDocumentViewModel(); CurrentPhysicalPersonDocumentForm.Identifier = Guid.NewGuid(); CurrentPhysicalPersonDocumentForm.ItemStatus = ItemStatus.Added; CurrentPhysicalPersonDocumentForm.IsSynced = false; return; } CurrentPhysicalPersonDocumentForm = new PhysicalPersonDocumentViewModel(); CurrentPhysicalPersonDocumentForm.Identifier = Guid.NewGuid(); CurrentPhysicalPersonDocumentForm.ItemStatus = ItemStatus.Added; CurrentPhysicalPersonDocumentForm.IsSynced = false; PhysicalPersonCreatedUpdated(); DisplayPhysicalPersonDocumentData(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtNote.Focus(); }) ); SubmitButtonEnabled = true; }); th.IsBackground = true; th.Start(); }
private void BtnDelete_Click(object sender, RoutedEventArgs e) { var response = new PhysicalPersonDocumentSQLiteRepository().SetStatusDeleted(CurrentPhysicalPersonDocumentDG.Identifier); if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik")); CurrentPhysicalPersonDocumentForm = new PhysicalPersonDocumentViewModel(); CurrentPhysicalPersonDocumentForm.Identifier = Guid.NewGuid(); CurrentPhysicalPersonDocumentForm.ItemStatus = ItemStatus.Added; CurrentPhysicalPersonDocumentDG = null; PhysicalPersonCreatedUpdated(); Thread displayThread = new Thread(() => DisplayPhysicalPersonDocumentData()); displayThread.IsBackground = true; displayThread.Start(); } else { MainWindow.ErrorMessage = response.Message; } }
public void DisplayPhysicalPersonDocumentData() { PhysicalPersonDocumentDataLoading = true; PhysicalPersonDocumentListResponse response = new PhysicalPersonDocumentSQLiteRepository() .GetPhysicalPersonDocumentsByPhysicalPerson(MainWindow.CurrentCompanyId, CurrentPhysicalPerson.Identifier); if (response.Success) { PhysicalPersonDocumentsFromDB = new ObservableCollection <PhysicalPersonDocumentViewModel>( response.PhysicalPersonDocuments ?? new List <PhysicalPersonDocumentViewModel>()); } else { PhysicalPersonDocumentsFromDB = new ObservableCollection <PhysicalPersonDocumentViewModel>(); } PhysicalPersonDocumentDataLoading = false; }