private void BtnDelete_Click(object sender, RoutedEventArgs e) { var response = new BusinessPartnerNoteSQLiteRepository().SetStatusDeleted(CurrentBusinessPartnerNoteDG.Identifier); if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik")); CurrentBusinessPartnerNoteForm = new BusinessPartnerNoteViewModel(); CurrentBusinessPartnerNoteForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerNoteForm.ItemStatus = ItemStatus.Added; CurrentBusinessPartnerNoteDG = null; BusinessPartnerCreatedUpdated(); Thread displayThread = new Thread(() => DisplayBusinessPartnerNoteData()); displayThread.IsBackground = true; displayThread.Start(); } else { MainWindow.ErrorMessage = response.Message; } }
public void DisplayBusinessPartnerNoteData() { BusinessPartnerNoteDataLoading = true; BusinessPartnerNoteListResponse response = new BusinessPartnerNoteSQLiteRepository() .GetBusinessPartnerNotesByBusinessPartner(MainWindow.CurrentCompanyId, CurrentBusinessPartner.Identifier); if (response.Success) { BusinessPartnerNotesFromDB = new ObservableCollection <BusinessPartnerNoteViewModel>( response.BusinessPartnerNotes ?? new List <BusinessPartnerNoteViewModel>()); } else { BusinessPartnerNotesFromDB = new ObservableCollection <BusinessPartnerNoteViewModel>(); } BusinessPartnerNoteDataLoading = false; }
private void btnAddNote_Click(object sender, RoutedEventArgs e) { #region Validation if (CurrentBusinessPartnerNoteForm.Note == null) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Napomena")); return; } #endregion Thread th = new Thread(() => { SubmitButtonEnabled = false; CurrentBusinessPartnerNoteForm.BusinessPartner = CurrentBusinessPartner; CurrentBusinessPartnerNoteForm.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentBusinessPartnerNoteForm.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; new BusinessPartnerNoteSQLiteRepository().Delete(CurrentBusinessPartnerNoteForm.Identifier); var response = new BusinessPartnerNoteSQLiteRepository().Create(CurrentBusinessPartnerNoteForm); if (!response.Success) { MainWindow.ErrorMessage = response.Message; CurrentBusinessPartnerNoteForm = new BusinessPartnerNoteViewModel(); CurrentBusinessPartnerNoteForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerNoteForm.ItemStatus = ItemStatus.Added; CurrentBusinessPartnerNoteForm.IsSynced = false; return; } CurrentBusinessPartnerNoteForm = new BusinessPartnerNoteViewModel(); CurrentBusinessPartnerNoteForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerNoteForm.ItemStatus = ItemStatus.Added; CurrentBusinessPartnerNoteForm.IsSynced = false; BusinessPartnerCreatedUpdated(); DisplayBusinessPartnerNoteData(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtNote.Focus(); }) ); SubmitButtonEnabled = true; }); th.IsBackground = true; th.Start(); }