Example #1
0
        private async void SignUp()
        {
            if (CanSave())
            {
                NewUser = new User()
                {
                    name = this.UserName, password = this.HashPassword(UserPassword)
                };
                UserCollection.Add(NewUser);
                await _userDataService.AddUserAsync(NewUser);

                NavigateToSignInView();
            }
        }
        private async void OnLoginComplete(UserDto googleUser, string message)
        {
            if (googleUser != null)
            {
                await _userDataService.AddUserAsync(googleUser);

                googleUser = await _userDataService.GetUserByGoogleIDAsync(googleUser.GoogleID);


                _userDataService.CurrentUser = googleUser;
                SettingsHelper.UserId        = googleUser.ID;

                UserDialogs.Instance.Toast(_validationService.RemarkRegistrationCompletedSuccessfully);

                await NavigationService.NavigateAsync("/NavigationPage/MasterTabbedPageView");
            }
            else
            {
                await UserDialogs.Instance.AlertAsync(message, "Warning", "OK");
            }
        }
        async void ExecuteTologinPageAfterRegistration()
        {
            if (String.IsNullOrWhiteSpace(CurrentUser.Username))
            {
                UserDialogs.Instance.Toast(_validationService.RemarkToUsername);
                return;
            }

            var userProfile = await _userDataService.GetUserByUsernameAsync(CurrentUser.Username);

            if (userProfile != null)
            {
                await UserDialogs.Instance.AlertAsync(_validationService.RemarkUsernameExists, "Warning", "OK");

                return;
            }

            if (String.IsNullOrWhiteSpace(CurrentUser.FirstName))
            {
                UserDialogs.Instance.Toast(_validationService.RemarkFirstName);
                return;
            }
            else if (String.IsNullOrWhiteSpace(CurrentUser.LastName))
            {
                UserDialogs.Instance.Toast(_validationService.RemarkLastName);
                return;
            }
            else if (String.IsNullOrWhiteSpace(CurrentUser.Email) || _validationService.ValidateEmail(CurrentUser.Email))
            {
                UserDialogs.Instance.Toast(_validationService.RemarkEmailName);
                return;
            }

            switch (_validationService.ValidatePassword(CurrentUser.Password, RepeatPassword))
            {
            case PasswordValidationEnum.Ok:
            {
                //var newUserProfile = new User()
                //{
                //    Username = this.Username,
                //    FirstName = this.FirstName,
                //    LastName = this.LastName,
                //    GoogleID = string.Empty,
                //    Email = this.Email,
                //    Password = this.Password
                //};

                await _userDataService.AddUserAsync(CurrentUser);

                UserDialogs.Instance.Toast(_validationService.RemarkRegistrationCompletedSuccessfully);

                await NavigationService.NavigateAsync("/NavigationPage/WelcomeView/LoginView");

                break;
            }

            case PasswordValidationEnum.TooShort:
            {
                UserDialogs.Instance.Toast(_validationService.RemarkPasswordLenght);
                CurrentUser.Password = string.Empty;
                RepeatPassword       = string.Empty;
                //return;
                break;
            }

            case PasswordValidationEnum.NotEqual:
            {
                await UserDialogs.Instance.AlertAsync(_validationService.RemarkPasswordNotEqual, "Error", "OK");

                CurrentUser.Password = string.Empty;
                RepeatPassword       = string.Empty;
                //return;
                break;
            }
            }
        }