private void btnAddNote_Click(object sender, RoutedEventArgs e) { #region Validation if (CurrentPhysicalPersonProfessionForm.Country == null) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_polje_drzava")); return; } #endregion Thread th = new Thread(() => { SubmitButtonEnabled = false; CurrentPhysicalPersonProfessionForm.PhysicalPerson = CurrentPhysicalPerson; CurrentPhysicalPersonProfessionForm.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentPhysicalPersonProfessionForm.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; new PhysicalPersonProfessionSQLiteRepository().Delete(CurrentPhysicalPersonProfessionForm.Identifier); var response = new PhysicalPersonProfessionSQLiteRepository().Create(CurrentPhysicalPersonProfessionForm); if (!response.Success) { MainWindow.ErrorMessage = response.Message; CurrentPhysicalPersonProfessionForm = new PhysicalPersonProfessionViewModel(); CurrentPhysicalPersonProfessionForm.Identifier = Guid.NewGuid(); CurrentPhysicalPersonProfessionForm.ItemStatus = ItemStatus.Added; CurrentPhysicalPersonProfessionForm.IsSynced = false; return; } CurrentPhysicalPersonProfessionForm = new PhysicalPersonProfessionViewModel(); CurrentPhysicalPersonProfessionForm.Identifier = Guid.NewGuid(); CurrentPhysicalPersonProfessionForm.ItemStatus = ItemStatus.Added; CurrentPhysicalPersonProfessionForm.IsSynced = false; PhysicalPersonCreatedUpdated(); DisplayPhysicalPersonProfessionData(); 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 PhysicalPersonProfessionSQLiteRepository().SetStatusDeleted(CurrentPhysicalPersonProfessionDG.Identifier); if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik")); CurrentPhysicalPersonProfessionForm = new PhysicalPersonProfessionViewModel(); CurrentPhysicalPersonProfessionForm.Identifier = Guid.NewGuid(); CurrentPhysicalPersonProfessionForm.ItemStatus = ItemStatus.Added; CurrentPhysicalPersonProfessionDG = null; PhysicalPersonCreatedUpdated(); Thread displayThread = new Thread(() => DisplayPhysicalPersonProfessionData()); displayThread.IsBackground = true; displayThread.Start(); } else { MainWindow.ErrorMessage = response.Message; } }
public void DisplayPhysicalPersonProfessionData() { PhysicalPersonProfessionDataLoading = true; PhysicalPersonProfessionListResponse response = new PhysicalPersonProfessionSQLiteRepository() .GetPhysicalPersonProfessionsByPhysicalPerson(MainWindow.CurrentCompanyId, CurrentPhysicalPerson.Identifier); if (response.Success) { PhysicalPersonProfessionsFromDB = new ObservableCollection <PhysicalPersonProfessionViewModel>( response.PhysicalPersonProfessions ?? new List <PhysicalPersonProfessionViewModel>()); } else { PhysicalPersonProfessionsFromDB = new ObservableCollection <PhysicalPersonProfessionViewModel>(); } PhysicalPersonProfessionDataLoading = false; }