private async Task ExecuteUpdateSessionsCommandAsync() { lock (_lockObject) { if (IsLoading || !UpdateSessionsCommand.CanExecute(null)) { return; } } lock (_lockObject) { IsLoading = true; } try { await _courseService.UpdateCourseSessionsAsync(Course); } catch (ConnectionException) { await DialogService.ShowMessageBox(Loc.GetLocalizedString(Localized.NoInternetConnection), Loc.GetLocalizedString(Localized.SomethingWrong)).ConfigureAwait(true); } catch (DataSourceException exc) { LoggingService.Report(exc.InnerException ?? exc, this); await DialogService.ShowMessageBox(Loc.GetLocalizedString(Localized.ConnectionProblem), Loc.GetLocalizedString(Localized.SomethingWrong)).ConfigureAwait(true); } lock (_lockObject) { IsLoading = false; } }
public async Task ActivateAsync() { lock (_lockObject) { if (IsLoading || _isLoaded) { return; } } DispatcherHelper.ExecuteOnUiThread(() => { lock (_lockObject) { IsLoading = true; } }); try { var categories = await _categoryService.GetAllCategoriesAsync().ConfigureAwait(true); Categories.Fill(categories); var identity = await AuthService.GetIdentityAsync().ConfigureAwait(true); Identity = identity; } catch (ConnectionException) { await DialogService.ShowMessageBox(Loc.GetLocalizedString(Localized.NoInternetConnection), Loc.GetLocalizedString(Localized.SomethingWrong)).ConfigureAwait(true); } catch (DataSourceException exc) { LoggingService.Report(exc.InnerException ?? exc, this); await DialogService.ShowMessageBox(Loc.GetLocalizedString(Localized.ConnectionProblem), Loc.GetLocalizedString(Localized.SomethingWrong)).ConfigureAwait(true); } finally { DispatcherHelper.ExecuteOnUiThread(() => { lock (_lockObject) { IsLoading = false; _isLoaded = true; } }); } }
public async Task ActivateAsync() { lock (_lockObject) { if (IsLoading || Category == null) { return; } } DispatcherHelper.ExecuteOnUiThread(() => { lock (_lockObject) { IsLoading = true; } }); try { var category = await _categoryService.GetCategoryDetailsAsync(Category.Id).ConfigureAwait(true); _courseService.FetchCoursesSpeculativelyAsync(category.Subcategories.ToArray()).ConfigureAwait(true); lock (_lockObject) { DispatcherHelper.ExecuteOnUiThread(() => { Category.Subcategories.Fill(category.Subcategories); }); } } catch (ConnectionException) { await DialogService.ShowMessageBox(Loc.GetLocalizedString(Localized.NoInternetConnection), Loc.GetLocalizedString(Localized.SomethingWrong)).ConfigureAwait(true); } catch (DataSourceException exc) { LoggingService.Report(exc.InnerException ?? exc, this); await DialogService.ShowMessageBox(Loc.GetLocalizedString(Localized.ConnectionProblem), Loc.GetLocalizedString(Localized.SomethingWrong)).ConfigureAwait(true); } finally { DispatcherHelper.ExecuteOnUiThread(() => { lock (_lockObject) { IsLoading = false; } }); } }
private async Task UpdateSearchStatusAsync(SearchStatus searchStatus) { var bar = StatusBar.GetForCurrentView(); switch (searchStatus) { case SearchStatus.Searching: bar.ProgressIndicator.Text = Loc.GetLocalizedString(Localized.Searching); await bar.ProgressIndicator.ShowAsync(); break; default: await bar.ProgressIndicator.HideAsync(); break; } }
private async Task SendContactInfoAsync(ContactType contactType) { Messenger.Default.Send(new SubmittingMessage(true)); try { switch (contactType) { case ContactType.Form: await _contactService.SendContactFormAsync(Session.Id, ContactForm).ConfigureAwait(true); ParticipantToAdd = new Participant(); break; case ContactType.Subscription: await _contactService.SendSubscriptionAsync(Session.Id, Subscription).ConfigureAwait(true); break; case ContactType.Feedback: await _contactService.SendFeedbackAsync(Session.Id, ScoredFeedback).ConfigureAwait(true); break; default: throw new ArgumentOutOfRangeException(nameof(contactType), contactType, null); } } catch (ConnectionException) { await DialogService.ShowError(Loc.GetLocalizedString(Localized.ConnectionProblem), Loc.GetLocalizedString(Localized.NoInternetConnection), null, null).ConfigureAwait(true); } finally { Messenger.Default.Send(new SubmittingMessage(false)); } }
public async Task ActivateAsync() { lock (_lockObject) { if (IsLoading || Course == null) { return; } } DispatcherHelper.ExecuteOnUiThread(() => { lock (_lockObject) { IsLoading = true; } }); try { if (Course.GetDetailLevel() < 2 || _refreshInNewLanguage) { var detailed = await _courseService.GetCourseDetailsAsync(Course.Id).ConfigureAwait(true); DispatcherHelper.ExecuteOnUiThread(() => { Course = detailed; #if DEBUG // API doesn't work, so we add fake data if (Course.Instructor == null) { Course.Instructor = new Instructor { Email = "*****@*****.**", Employer = "RealDolmen NV", EmployerDepartment = "Professional Services", FirstName = "FirstName", LastName = "LastName", Gender = "m", Id = 1, IsActive = true, Language = "nl" }; } if (Course.Description == null) { Course.Descriptions.Add(new Description { Audience = "Padawans", CourseContent = "You will learn the ways of the Force", CourseId = Course.Id, ExternalUrl = "https://education.realdolmen.com", Language = "nl", LongDescription = "This is a longer description.", ShortDescription = "This is a short description.", Materials = "Lightsaber", Methods = "Mind control", Objectives = "You can feel the Force around you", Platforms = "Light Side", Prerequisites = "You'll need some midi-chlorians" }); } if (Course.ContentUrl.IsNullOrWhiteSpace()) { Course.ContentUrl = "https://education.realdolmen.com"; } if (Course.Publisher.IsNullOrWhiteSpace()) { Course.Publisher = "RealDolmen NV"; } if (Course.StartDate == null) { Course.StartDate = DateTime.Now.AddDays(1); } #endif SwitchDescriptionCommand.Execute(null); }); } } catch (ConnectionException) { await DialogService.ShowMessageBox(Loc.GetLocalizedString(Localized.NoInternetConnection), Loc.GetLocalizedString(Localized.SomethingWrong)).ConfigureAwait(true); } catch (DataSourceException exc) { LoggingService.Report(exc.InnerException ?? exc, this); await DialogService.ShowMessageBox(Loc.GetLocalizedString(Localized.ConnectionProblem), Loc.GetLocalizedString(Localized.SomethingWrong)).ConfigureAwait(true); } finally { DispatcherHelper.ExecuteOnUiThread(() => { lock (_lockObject) { IsLoading = false; } }); _refreshInNewLanguage = false; } }