Пример #1
0
        private async void OnRegisterCommand()
        {
            RegisterErrorMsg = null;
            if (RegisterUserName == null || RegisterPassword == null || RegisterConfirmPassword == null || RegisterFirstName == null || RegisterLastName == null || RegisterEmail == null)
            {
                RegisterErrorMsg = MessageNames.RegisterBlank;
            }
            else
            {
                RegisterErrorMsg = ValidationUtilities.ValidateInput(RegisterFirstName);
                if (RegisterErrorMsg == null)
                {
                    RegisterErrorMsg = ValidationUtilities.ValidateInput(RegisterLastName);
                    if (RegisterErrorMsg == null)
                    {
                        RegisterErrorMsg = ValidationUtilities.ValidateInput(RegisterUserName);
                        if (RegisterErrorMsg == null)
                        {
                            if (RegexUtilities.IsValidEmail(RegisterEmail))
                            {
                                RegisterErrorMsg = ValidationUtilities.ValidatePassword(RegisterPassword);
                                if (RegisterErrorMsg == null)
                                {
                                    if (RegisterPassword != RegisterConfirmPassword)
                                    {
                                        RegisterErrorMsg = MessageNames.RegisterWrongPasswords;
                                    }
                                    else
                                    {
                                        try
                                        {
                                            _userName.FirstName = RegisterFirstName;
                                            _userName.LastName  = RegisterLastName;
                                            _userName.UserName  = RegisterUserName;
                                            _userName.Password  = RegisterPassword;
                                            _userName.Email     = RegisterEmail;
                                            await _userDataService.RegisterUser(_userName);
                                        }
                                        catch (Exception)
                                        {
                                            RegisterErrorMsg = MessageNames.RegisterUniqueException;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                RegisterErrorMsg = MessageNames.RegisterWrongEmail;
                            }
                        }
                    }
                }
            }

            if (RegisterErrorMsg == null)
            {
                MessagingCenter.Send(this, MessageNames.RegisterdUser);
                _navigationService.GoBack();
            }
        }