private async void RecoverAction()
{
IsSending = true;
if (string.IsNullOrEmpty(_passwordRecoveryData))
{
ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
AppResourcesHelper.Get("Main_UploadProgramMissingRecoveryData"), MissingRecoveryDataCallback, MessageBoxOptions.Ok);
}
else
{
JSONStatusResponse statusResponse = await ServiceLocator.WebCommunicationService.RecoverPasswordAsync(_passwordRecoveryData, ServiceLocator.CultureService.GetCulture().TwoLetterISOLanguageName);
if (statusResponse.statusCode == StatusCodes.ServerResponseOk)
{
// since 08-2014 this only works on the test-server (https://catroid-test.catrob.at/)
//string recoveryLink = statusResponse.answer;
//string hashMarker = "?c=";
//int position = recoveryLink.LastIndexOf(hashMarker) + hashMarker.Length;
//string recoveryHash = recoveryLink.Substring(position, recoveryLink.Length - position);
//ServiceLocator.WebCommunicationService.SetRecoveryHash(recoveryHash);
//ResetViewModel();
//ServiceLocator.NavigationService.NavigateTo<UploadProgramNewPasswordViewModel>();
//ServiceLocator.NavigationService.RemoveBackEntry();
// since 08-2014 pocketcode-server sends an email with the recovery hash in it
ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramRecoverPassword"),
statusResponse.answer, MissingRecoveryDataCallback, MessageBoxOptions.Ok);
this.GoBackAction();
}
else
{
switch (statusResponse.statusCode)
{
case StatusCodes.HTTPRequestFailed:
ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
AppResourcesHelper.Get("Main_NoInternetConnection"), MissingRecoveryDataCallback, MessageBoxOptions.Ok);
break;
default:
string messageString = string.IsNullOrEmpty(statusResponse.answer) ? string.Format(AppResourcesHelper.Get("Main_UploadProgramUndefinedError"), statusResponse.statusCode.ToString()) :
string.Format(AppResourcesHelper.Get("Main_UploadProgramLoginError"), statusResponse.answer);
ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
messageString, MissingRecoveryDataCallback, MessageBoxOptions.Ok);
break;
}
}
}
IsSending = false;
}