Ejemplo n.º 1
0
        private async void RegisterAccountAsync()
        {
            if (this.ViewModel.AllInputFilledOut())
            {
                UserNetworkManager manager = new UserNetworkManager();
                this.CustomActivityIndicator.IsRunning = true;
                User user = await manager.RegisterUser(this.ViewModel.GenerateUserFromInput());

                if (user.Success && string.IsNullOrEmpty(user.Message))
                {
                    await DisplayAlert("Success", $"Your account has been created", "Continue");

                    // save user login data to app data
                    Application.Current.Properties["User"] = ObjectSerializerHelper.ConvertObjectToBase64(user);
                    await Application.Current.SavePropertiesAsync();

                    Application.Current.MainPage = new BaseNavigationPage(new ManageImageFileContentPage(user));
                }
                else
                {
                    await DisplayAlert("Register Account Error", $"{user.Message}", "OK");
                }
                this.CustomActivityIndicator.IsRunning = false;
            }
            else
            {
                await DisplayAlert("Register Account Error", $"Please fill out all inputs correctly and accept terms of use.", "OK");
            }
        }
Ejemplo n.º 2
0
        private async void ValidateLoginAsync()
        {
            //Application.Current.MainPage = new BaseNavigationPage(new ManageImageFileContentPage());
            if (!String.IsNullOrEmpty(this.TextUsername) && !String.IsNullOrEmpty(this.TextPassword))
            {
                UserNetworkManager manager = new UserNetworkManager();

                this.CustomActivityIndicator.IsRunning = true;
                User user = await manager.LoginAsync(this.TextUsername, this.TextPassword);

                if (user.Success && String.IsNullOrEmpty(user.Message))
                {
                    // save user login data to app data
                    Application.Current.Properties["User"] = ObjectSerializerHelper.ConvertObjectToBase64(user);
                    await Application.Current.SavePropertiesAsync();

                    Application.Current.MainPage = new BaseNavigationPage(new ManageImageFileContentPage(user));
                }
                else
                {
                    await DisplayAlert("Error", $"{user.Message}", "OK");
                }
                this.CustomActivityIndicator.IsRunning = false;
            }
            else
            {
                await DisplayAlert("Error", $"Username and password is required.", "OK");
            }
        }
Ejemplo n.º 3
0
        public async Task <bool> UserMultipleSubscribe()
        {
            var manager = new UserNetworkManager();

            if (await manager.UserMultipleSubscribeAsync(User.AuthToken))
            {
                User.HasMultipleSubscription = true;
                // save user login data to app data
                Application.Current.Properties["User"] = ObjectSerializerHelper.ConvertObjectToBase64(User);
                await Application.Current.SavePropertiesAsync();

                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        private async void RecoverEmailAsync()
        {
            if (!string.IsNullOrEmpty(this.TextEmail))
            {
                UserNetworkManager manager = new UserNetworkManager();
                this.CustomActivityIndicator.IsRunning = true;
                bool success = await manager.SendEmailForRecovery(this.TextEmail.Trim());

                if (success)
                {
                    await DisplayAlert("Password Recovery", $"If an account exists with that email, you will receive an email within a few minutes", "OK");
                }
                else
                {
                    await DisplayAlert("Network Error", $"There was an issue with the network. Please try again later", "OK");
                }
                this.CustomActivityIndicator.IsRunning = false;
            }
            else
            {
                await DisplayAlert("Error", $"Please fill out the form before submitting", "OK");
            }
        }