private void BtnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (PhonebookDocumentsFromDB == null || PhonebookDocumentsFromDB.Count == 0) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Morate_uneti_osnovne_podatkeUzvičnik")); return; } #endregion Thread td = new Thread(() => { SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SubmitButtonEnabled = false; CurrentPhonebook.PhonebookDocuments = PhonebookDocumentsFromDB; PhonebookResponse response = PhonebookService.Create(CurrentPhonebook); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_čuvanja_na_serveruUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; } if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; PhonebookCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (currentPhonebook?.Name == null) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_NazivUzvičnik")); return; } #endregion Thread td = new Thread(() => { SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SubmitButtonEnabled = false; currentPhonebook.IsSynced = false; currentPhonebook.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; currentPhonebook.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; PhonebookResponse response = new PhonebookSQLiteRepository().Create(currentPhonebook); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_čuvanjaUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; } response = PhonebookService.Create(currentPhonebook); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Podaci_su_sačuvani_u_lokaluUzvičnikTačka_Greška_kod_čuvanja_na_serveruUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; } if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; new PhonebookSQLiteRepository().Sync(PhonebookService); PhonebookCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }