Catrobat.IDE.Core.ViewModels.Service.UploadProgramNewPasswordViewModel.NewPasswordAction C# (CSharp) Method

NewPasswordAction() private method

private NewPasswordAction ( ) : void
return void
        private async void NewPasswordAction()
        {
            IsSending = true;
            if (string.IsNullOrEmpty(_newPassword) || string.IsNullOrEmpty(_repeatedPassword))
            {
                ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                    AppResourcesHelper.Get("Main_UploadProgramMissingPassword"), MissingPasswordDataCallback, MessageBoxOptions.Ok);
            }
            else
            {
                JSONStatusResponse statusResponse = await ServiceLocator.WebCommunicationService.ChangePasswordAsync(_newPassword, _repeatedPassword, ServiceLocator.CultureService.GetCulture().TwoLetterISOLanguageName);

                switch (statusResponse.statusCode)
                {
                    case StatusCodes.ServerResponseOk:
                        this.GoBackAction();
                        ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramNewPassword"),
                            AppResourcesHelper.Get("Main_UploadProgramPasswordChangeSucess"), PasswordInvalidCallback, MessageBoxOptions.Ok);
                        break;

                    // because of typing-error in server-message
                    case StatusCodes.ServerResponseRecoveryHashNotFound:
                        ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                            AppResourcesHelper.Get("Main_UploadProgramRecoveryHashError"), RecoveryHashNotFoundCallback, MessageBoxOptions.Ok);
                        break;

                    // may be checked locally
                    case StatusCodes.ServerResponsePasswordMatchFailed:
                        ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                            AppResourcesHelper.Get("Main_UploadProgramRecoveryPasswordMatchError"), PasswordInvalidCallback, MessageBoxOptions.Ok);
                        break;

                    case StatusCodes.HTTPRequestFailed:
                        ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                            AppResourcesHelper.Get("Main_NoInternetConnection"), MissingPasswordDataCallback, MessageBoxOptions.Ok);
                        break;

                    default:
                        string messageString = string.IsNullOrEmpty(statusResponse.answer) ? string.Format(AppResourcesHelper.Get("Main_UploadProgramUndefinedError"), statusResponse.statusCode.ToString()) : statusResponse.answer;
                        ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                            messageString, MissingPasswordDataCallback, MessageBoxOptions.Ok);
                        break;
                }
            }
            IsSending = false;
        }