Esempio n. 1
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");
            }
        }
        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");
            }
        }
Esempio 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);
        }