private async void Resend() { SetWarning(false, string.Empty); this.EmailInputState = InputState.Normal; if (!NetworkService.HasInternetAccess(true)) { return; } if (!CheckInputParameters()) { return; } this.IsBusy = true; this.ControlState = false; this.ResendButtonState = false; var create = new CreateAccountRequestListenerAsync(); var result = await create.ExecuteAsync(() => { SdkService.MegaSdk.createAccount( this.Email, this.Password, this.FirstName, this.LastName, create); }); this.ControlState = true; this.ResendButtonState = true; this.IsBusy = false; string messageContent; switch (result) { case CreateAccountResult.Success: { messageContent = string.Format(ResourceService.AppMessages.GetString("AM_ConfirmEmail"), this.Email); break; } case CreateAccountResult.AlreadyExists: { messageContent = ResourceService.AppMessages.GetString("AM_EmailAlreadyRegistered"); break; } case CreateAccountResult.Unknown: { messageContent = ResourceService.AppMessages.GetString("AM_CreateAccountFailed"); break; } default: throw new ArgumentOutOfRangeException(); } await DialogService.ShowAlertAsync( ResourceService.AppMessages.GetString("AM_ConfirmEmail_Title"), messageContent); }
public async void CreateAccount() { SetWarning(false, string.Empty); SetInputState(); if (!CheckInputParameters()) { return; } if (CheckPassword()) { if (CheckPasswordStrenght()) { if (this.TermOfService) { this.IsBusy = true; this.ControlState = false; this.CreateAccountButtonState = false; var createAccount = new CreateAccountRequestListenerAsync(); var result = await createAccount.ExecuteAsync(() => { this.MegaSdk.createAccount( this.Email, this.Password, this.FirstName, this.LastName, createAccount); }); this.ControlState = true; this.CreateAccountButtonState = true; this.IsBusy = false; string messageContent; switch (result) { case CreateAccountResult.Success: { NavigateService.Instance.Navigate(typeof(ConfirmEmailPage), true, new NavigationObject { Action = NavigationActionType.Default, Parameters = new Dictionary <NavigationParamType, object> { { NavigationParamType.Email, this.Email }, { NavigationParamType.Password, this.Password }, { NavigationParamType.FirstName, this.FirstName }, { NavigationParamType.LastName, this.LastName }, } }); return; } case CreateAccountResult.AlreadyExists: { messageContent = ResourceService.AppMessages.GetString("AM_EmailAlreadyRegistered"); break; } case CreateAccountResult.Unknown: { messageContent = ResourceService.AppMessages.GetString("AM_CreateAccountFailed"); break; } default: throw new ArgumentOutOfRangeException(); } OnUiThread(async() => await DialogService.ShowAlertAsync(this.CreateAccountText, messageContent)); } else { SetWarning(true, ResourceService.AppMessages.GetString("AM_AgreeTermsOfService")); SetInputState(termsOfService: InputState.Warning); } } else { SetInputState(password: InputState.Warning, confirmPassword: InputState.Warning); SetWarning(true, ResourceService.AppMessages.GetString("AM_VeryWeakPassword")); } } else { SetInputState(password: InputState.Warning, confirmPassword: InputState.Warning); SetWarning(true, ResourceService.AppMessages.GetString("AM_PasswordsDoNotMatch")); } }