Пример #1
0
        public async Task DeleteProfile()
        {
            NewProfileViewModel profileViewModel = this;
            string        text1          = profileViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Profile_Message");
            string        str            = profileViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Profile_Title") + " - " + profileViewModel.UserName;
            string        text2          = profileViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Confirm");
            string        text3          = profileViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Cancel");
            ConfirmConfig confirmConfig1 = new ConfirmConfig();

            confirmConfig1.set_Message(text1);
            confirmConfig1.set_Title(str);
            confirmConfig1.set_OkText(text2);
            confirmConfig1.set_CancelText(text3);
            ConfirmConfig confirmConfig2 = confirmConfig1;

            if (profileViewModel._platformStyleProvider.DeleteConfirmationStyle != -1)
            {
                confirmConfig2.set_AndroidStyleId(new int?(profileViewModel._platformStyleProvider.DeleteConfirmationStyle));
            }
            if (!await profileViewModel._userDialogs.ConfirmAsync(confirmConfig2, new CancellationToken?()))
            {
                return;
            }
            profileViewModel.Busy();
            profileViewModel.DeleteProfileByCredential(profileViewModel._credentialsDataService);
            profileViewModel._credentialsDataService.DeleteCredential(profileViewModel.UserName, profileViewModel.Password);
            profileViewModel.SelectAnotherProfileForActiveProfile();
            profileViewModel.NotBusy();
        }
Пример #2
0
        private async Task ExecuteDeleteHomeWorkCommand(StudentHomeWorkRealm homework)
        {
            HomeWorkStudentDetailViewModel studentDetailViewModel = this;

            if (!studentDetailViewModel.HasInternetConnection)
            {
                // ISSUE: reference to a compiler-generated method
                ((MvxMainThreadDispatchingObject)studentDetailViewModel).InvokeOnMainThread(new Action(studentDetailViewModel.\u003CExecuteDeleteHomeWorkCommand\u003Eb__32_0), true);
            }
            else
            {
                string        text1          = studentDetailViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Message");
                string        text2          = studentDetailViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Title");
                string        text3          = studentDetailViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Confirm");
                string        text4          = studentDetailViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Cancel");
                ConfirmConfig confirmConfig1 = new ConfirmConfig();
                confirmConfig1.set_Message(text1);
                confirmConfig1.set_Title(text2);
                confirmConfig1.set_OkText(text3);
                confirmConfig1.set_CancelText(text4);
                ConfirmConfig confirmConfig2 = confirmConfig1;
                if (studentDetailViewModel._platformStyleProvider != null)
                {
                    confirmConfig2.set_AndroidStyleId(new int?(studentDetailViewModel._platformStyleProvider.DeleteConfirmationStyle));
                }
                if (!await studentDetailViewModel._userDialogs.ConfirmAsync(confirmConfig2, new CancellationToken?()))
                {
                    return;
                }
                try
                {
                    studentDetailViewModel.IsHomeWorkLoading = true;
                    await studentDetailViewModel._studentHomeWorkDataService.DeleteStudentHomeWorkAsync(studentDetailViewModel.ActiveProfileRealm, int.Parse(homework.Id));

                    StudentHomeWorkRealm studentHomeWorkRealm = await studentDetailViewModel._studentHomeWorkDataService.FetchStudentHomeworkAsync(studentDetailViewModel.ActiveProfileRealm, int.Parse(homework.Id));

                    await studentDetailViewModel.InitStudentHomeWorks(studentDetailViewModel.Lesson);
                }
                catch (Exception ex)
                {
                    if (ex is ServerValidationException validationException)
                    {
                        await studentDetailViewModel._userDialogs.AlertAsync(validationException.ValidationException.GetAggregatedValidationMessage(), validationException.ValidationException.Message, studentDetailViewModel._textProvider.GetText((string)null, (string)null, "Alert_ButtonOk_Text"), new CancellationToken?());
                    }
                    else
                    {
                        ErrorHandler.Current.HandleError(ex);
                    }
                }
                finally
                {
                    studentDetailViewModel.IsHomeWorkLoading = false;
                }
            }
        }
        private async Task DeleteProfile(Profile profile)
        {
            ProfilesViewModel profilesViewModel = this;

            if (profile == null)
            {
                return;
            }
            string        text1          = profilesViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Profile_Message");
            string        str            = profilesViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Profile_Title") + " - " + profile.Student?.Name;
            string        text2          = profilesViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Confirm");
            string        text3          = profilesViewModel._textProvider.GetText((string)null, (string)null, "Common_Delete_Cancel");
            ConfirmConfig confirmConfig1 = new ConfirmConfig();

            confirmConfig1.set_Message(text1);
            confirmConfig1.set_Title(str);
            confirmConfig1.set_OkText(text2);
            confirmConfig1.set_CancelText(text3);
            ConfirmConfig confirmConfig2 = confirmConfig1;

            if (profilesViewModel._platformStyleProvider.DeleteConfirmationStyle != -1)
            {
                confirmConfig2.set_AndroidStyleId(new int?(profilesViewModel._platformStyleProvider.DeleteConfirmationStyle));
            }
            if (!await profilesViewModel._userDialogs.ConfirmAsync(confirmConfig2, new CancellationToken?()))
            {
                return;
            }
            try
            {
                profilesViewModel.IsLoading = profilesViewModel._settings.RefreshProfileInProgress = true;
                profilesViewModel._messenger.Publish <ProfileSyncMessage>((M0) new ProfileSyncMessage((object)profilesViewModel, profilesViewModel.IsLoading));
                try
                {
                    if (profile.PushSettings.IsPushActive)
                    {
                        int num = await profilesViewModel._profileDataService.NotificationDeleteAsync(profile, false).ConfigureAwait(false) ? 1 : 0;
                    }
                }
                catch (Exception ex)
                {
                    CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, "ProfileDeleteCommand || NotificationDeleteAsync", "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/ViewModels/ProfilesViewModel.cs", 149);
                }
                profilesViewModel._authDataService.DeleteProfile(profile);
                if (!profilesViewModel.SetFirstProfileActive())
                {
                    int num1 = await profilesViewModel._navigationService.Navigate <LoginViewModel>((IMvxBundle)null, new CancellationToken()) ? 1 : 0;
                }
                profilesViewModel._messenger.Publish <ActiveProfileChangedMessage>((M0) new ActiveProfileChangedMessage((object)profilesViewModel, profile));
                profilesViewModel.SelectedItem = (Profile)null;
            }
            catch (Exception ex)
            {
                CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, "ProfileDeleteCommand || " + ex.Source, "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/ViewModels/ProfilesViewModel.cs", 163);
                ErrorHandler.Current.HandleError(ex);
            }
            finally
            {
                profilesViewModel.IsLoading = profilesViewModel._settings.RefreshProfileInProgress = false;
                profilesViewModel._messenger.Publish <ProfileSyncMessage>((M0) new ProfileSyncMessage((object)profilesViewModel, profilesViewModel.IsLoading));
            }
            profilesViewModel.GetProfiles();
        }