private void BtnDelete_Click(object sender, RoutedEventArgs e) { var response = new PhysicalPersonLicenceSQLiteRepository().SetStatusDeleted(CurrentPhysicalPersonLicenceDG.Identifier); if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik")); CurrentPhysicalPersonLicenceForm = new PhysicalPersonLicenceViewModel(); CurrentPhysicalPersonLicenceForm.Identifier = Guid.NewGuid(); CurrentPhysicalPersonLicenceForm.ItemStatus = ItemStatus.Added; CurrentPhysicalPersonLicenceDG = null; PhysicalPersonCreatedUpdated(); Thread displayThread = new Thread(() => DisplayPhysicalPersonLicenceData()); displayThread.IsBackground = true; displayThread.Start(); } else { MainWindow.ErrorMessage = response.Message; } }
public void DisplayPhysicalPersonLicenceData() { PhysicalPersonLicenceDataLoading = true; PhysicalPersonLicenceListResponse response = new PhysicalPersonLicenceSQLiteRepository() .GetPhysicalPersonLicencesByPhysicalPerson(MainWindow.CurrentCompanyId, CurrentPhysicalPerson.Identifier); if (response.Success) { PhysicalPersonLicencesFromDB = new ObservableCollection <PhysicalPersonLicenceViewModel>( response.PhysicalPersonLicences ?? new List <PhysicalPersonLicenceViewModel>()); } else { PhysicalPersonLicencesFromDB = new ObservableCollection <PhysicalPersonLicenceViewModel>(); } PhysicalPersonLicenceDataLoading = false; }
private void btnAddNote_Click(object sender, RoutedEventArgs e) { #region Validation if (CurrentPhysicalPersonLicenceForm.Country == null) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_polje_drzava")); return; } if (CurrentPhysicalPersonLicenceForm.Licence == null) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_polje_licenca")); return; } #endregion Thread th = new Thread(() => { SubmitButtonEnabled = false; CurrentPhysicalPersonLicenceForm.PhysicalPerson = CurrentPhysicalPerson; CurrentPhysicalPersonLicenceForm.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentPhysicalPersonLicenceForm.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; new PhysicalPersonLicenceSQLiteRepository().Delete(CurrentPhysicalPersonLicenceForm.Identifier); var response = new PhysicalPersonLicenceSQLiteRepository().Create(CurrentPhysicalPersonLicenceForm); if (!response.Success) { MainWindow.ErrorMessage = response.Message; CurrentPhysicalPersonLicenceForm = new PhysicalPersonLicenceViewModel(); CurrentPhysicalPersonLicenceForm.Identifier = Guid.NewGuid(); CurrentPhysicalPersonLicenceForm.ItemStatus = ItemStatus.Added; CurrentPhysicalPersonLicenceForm.IsSynced = false; return; } CurrentPhysicalPersonLicenceForm = new PhysicalPersonLicenceViewModel(); CurrentPhysicalPersonLicenceForm.Identifier = Guid.NewGuid(); CurrentPhysicalPersonLicenceForm.ItemStatus = ItemStatus.Added; CurrentPhysicalPersonLicenceForm.IsSynced = false; PhysicalPersonCreatedUpdated(); DisplayPhysicalPersonLicenceData(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { //txtNote.Focus(); }) ); SubmitButtonEnabled = true; }); th.IsBackground = true; th.Start(); }