Пример #1
0
        public void Register(string user, string password, string repeatPassword)
        {
            Helper helper = new Helper(this.driver);

            helper.Navigate(this.driver);
            Helper.Wait(this.driver);
            RegisterLink.Click();
            Username.SendKeys(user);
            Password.SendKeys(password);
            RepeatPassword.SendKeys(repeatPassword);
            RegisterButton.Click();
        }
Пример #2
0
 private void Signup_Click(object sender, EventArgs e)
 {
     if (SignupPassword.Text == RepeatPassword.Text)
     {
         User = new Profile(SignupName.Text, SignupUsername.Text, SignupPassword.Text, SelectProfilePicture.BackgroundImage);
         string folderName = System.IO.Directory.GetCurrentDirectory();
         string subFolder1 = User.ProfileName + User.Password;
         string push       = subFolder1 + @"\Books";
         string pathString = System.IO.Path.Combine(folderName, push);
         string path       = System.IO.Path.Combine(folderName, subFolder1);
         if (System.IO.Directory.Exists(pathString))
         {
             MessageBox.Show("Account already exists, do you wish to login?", "signup error");
         }
         else
         {
             System.IO.Directory.CreateDirectory(pathString);
             string fileName      = User.ProfileName + ".txt";
             string newPathString = System.IO.Path.Combine(path, fileName);
             using (StreamWriter writer = new StreamWriter(newPathString))
             {
                 writer.WriteLine(User.ProfileName);
                 writer.WriteLine(User.Password);
                 writer.WriteLine(User.UserName);
             }
             MyApp.SelectedIndex = 3;
             SignupName.Clear();
             SignupUsername.Clear();
             SignupPassword.Clear();
             SelectProfilePicture.BackgroundImage = null;
         }
     }
     else
     {
         MessageBox.Show("Unsure Password", "signup error");
         SignupPassword.Clear();
         RepeatPassword.Clear();
     }
 }
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Email.Length < 6 && !Email.Contains("@"))
            {
                yield return(new ValidationResult("Niepoprawny adres email", new[] { "Email" }));
            }

            if (Password.Length < 6)
            {
                yield return(new ValidationResult("Hasło musi zawierać minimum 6 znaków", new[] { "Password" }));
            }

            if (IsValidBirthDay())
            {
                yield return(new ValidationResult("Musisz mieć ukończone 18 lat", new[] { "DateOfBirth" }));
            }

            if (!RepeatPassword.Equals(Password))
            {
                yield return(new ValidationResult("Hasła różnią się", new[] { "RepeatPassword" }));
            }
        }
        public async void UpdateCommandExecute()
        {
            bool updateCredentials = false;
            RestServiceConsumer service;

            SetActivity(true);
            //Conexion
            service = new RestServiceConsumer();
            var response = await service.CheckConnection();

            if (!response.IsSuccesFull)
            {
                SetActivity(false);
                //No hay conexion
                CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                response.Message, iconResource: "error64", textSize: 16);
                return;
            }
            try
            {
                //Chequeo de vacios
                if (!AllDataChecker())
                {
                    //Faltan datos
                    SetActivity(false);
                    CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                    Languages.AllDataNeeded, iconResource: "error64", textSize: 16);
                    return;
                }

                if (!NameChecker(this.Nombres.TrimEnd(' ')) || !NameChecker(this.Apellidos.TrimEnd(' ')))
                {
                    SetActivity(false);
                    //Los nombres o apellidos no han sido bien escritos}
                    if (!NameChecker(this.Nombres.TrimEnd(' ')))
                    {
                        CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                        Languages.WronWGNames, iconResource: "error64", textSize: 16);
                    }
                    else
                    {
                        CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                        Languages.WronWGivenNames, iconResource: "error64", textSize: 16);
                    }
                    return;
                }

                //Chequeo de password correcto
                if (Settings.SuccesfullPassword != this.OldPassword)
                {
                    SetActivity(false);
                    //No coinciden las contraseñas
                    CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                    Languages.PasswordsDontMatch, iconResource: "error64", textSize: 16);
                    return;
                }

                //Se quiere actualizar algo de la seccion de credenciales?
                if (!this.NewPassword.Equals(string.Empty) || !this.RepeatPassword.Equals(string.Empty))
                {
                    //Todos los datos fueron proporcionados?
                    if (NewPassword.Equals(string.Empty) || RepeatPassword.Equals(string.Empty))
                    {
                        SetActivity(false);
                        CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                        Languages.AllDataNeeded, iconResource: "error64", textSize: 16);
                        return;
                    }
                    //Chequeo de repeticion de nueva contraseña
                    if (this.NewPassword != this.RepeatPassword)
                    {
                        SetActivity(false);
                        //No coinciden las contraseñas
                        CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                        Languages.PasswordsShouldMatch, iconResource: "error64", textSize: 16);
                        return;
                    }
                    else
                    {
                        updateCredentials = true;
                    }
                }


                //Creacion del modelo a enviar
                Stream streamedImage = GetImageSourceStream(this.Profile.ProfileImage);
                this.ProfileImageBytes = StreamToByteArray(streamedImage);


                var token = Settings.SerializedToken;

                var posted = new ApiPlainClientProfile()
                {
                    ID              = Settings.ClientUID,
                    PrimerNombre    = this.Nombres.Split(' ')[0],
                    SegundoNombre   = this.Nombres.Split(' ')[1],
                    Apellido        = this.Apellidos.Split(' ')[0],
                    SegundoApellido = this.Apellidos.Split(' ')[1],
                    Email           = this.Profile.Email,
                    PP              = this.ProfileImageBytes,
                    Afiliado        = DateTime.Now
                };

                var posted2 = new ApiClientCredentials()
                {
                    IdClient  = -1,
                    IdPersona = posted.ID,
                    Password  = this.NewPassword,
                    UserName  = "******"
                };

                Response result2 = null;
                var      result  = await service.Put <ApiPlainClientProfile>(Constantes.BASEURL, Constantes.CLIENTPREFIX, Constantes.CLIENTUPDATEPROFILE, posted, token);

                if (updateCredentials)
                {
                    result2 = await service.Put <ApiClientCredentials>(Constantes.BASEURL, Constantes.CLIENTPREFIX, Constantes.CLIENTUPDATECREDENTIALS, posted2, token);
                }

                if (updateCredentials)
                {
                    if (!result.IsSuccesFull || !result2.IsSuccesFull)
                    {
                        SetActivity(false);
                        //Error en la peticion
                        if (!result.IsSuccesFull)
                        {
                            CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                            result.Message, iconResource: "error64", textSize: 16);
                            SetActivity(false);
                            return;
                        }
                        else
                        {
                            CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                            result2.Message, iconResource: "error64", textSize: 16);
                        }
                        SetActivity(false);
                        return;
                    }
                    Settings.SuccesfullPassword = this.NewPassword;
                }
                else
                {
                    if (!result.IsSuccesFull)
                    {
                        CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                        result.Message, iconResource: "error64", textSize: 16);
                        SetActivity(false);
                        return;
                    }
                }

                SetActivity(false);
                CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                Languages.UpdatedProfile, iconResource: "ok96", textSize: 16);
                UpdateLocalProfileInfo(posted);
            }
            catch (Exception ex)
            {
                CustomizedToast(Android.Graphics.Color.White, Android.Graphics.Color.Black,
                                ex.Message, iconResource: "error64", textSize: 16);
                SetActivity(false);
                throw ex;
            }
        }
Пример #5
0
 private void Clear()
 {
     OldPassword.Clear();
     NewPassword.Clear();
     RepeatPassword.Clear();
 }