Пример #1
0
        private async void RegistracijaButton_Clicked(object sender, EventArgs e)
        {
            string greska = null;

            if (string.IsNullOrEmpty(Ime.Text))
            {
                greska = "Ime je obavezno!";
            }
            else if (string.IsNullOrEmpty(Prezime.Text))
            {
                greska = "Prezime je obavezno!";
            }
            else if (string.IsNullOrEmpty(Telefon.Text))
            {
                greska = "Telefon je obavezan!";
            }
            else if (string.IsNullOrEmpty(Email.Text))
            {
                greska = "Email je obavezan!";
            }
            else if (string.IsNullOrEmpty(KorisnickoIme.Text))
            {
                greska = "Korisničko ime je obavezno!";
            }
            else if (string.IsNullOrEmpty(Lozinka.Text))
            {
                greska = "Lozinka je obavezna!";
            }
            else if (Lozinka.Text.Length < 8)
            {
                greska = "Lozinka ne smije biti kraća od 8 karaktera.";
            }
            else if (Lozinka.Text != PotvrdaLozinke.Text)
            {
                greska = "Lozinke se ne podudaraju!";
            }

            if (greska != null)
            {
                await DisplayAlert("myBooks", greska, "Zatvori");

                return;
            }

            try
            {
                await _model.Registracija();

                await DisplayAlert("myBooks", "Registracija uspješna. Molimo prijavite se.", "Zatvori");

                Application.Current.MainPage = new PrijavaPage(KorisnickoIme.Text);
            }
            catch
            {
                _model.IsBusy = false;

                await DisplayAlert("myBooks", "Dogodila se greška prilikom registracije. Molimo pokušajte ponovo.", "Zatvori");
            }
        }
Пример #2
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            if (!Regex.IsMatch(this.Ime.Text, @"^[a-zA-Z]+$"))
            {
                await DisplayAlert("Greška", "Ime se sastoji samo od slova", "OK");
            }
            else if (!Regex.IsMatch(this.Prezime.Text, @"^[a-zA-Z]+$"))
            {
                await DisplayAlert("Greška", "Prezime se sastoji samo od slova", "OK");
            }
            else if (!Regex.IsMatch(this.Email.Text, @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"))
            {
                await DisplayAlert("Greška", "E-mail format nije ispravan!", "OK");
            }
            else if (!Regex.IsMatch(this.KorisnickoIme.Text, @"^(?=.{4,40}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$"))
            {
                await DisplayAlert("Greška", "Korisničko ime nije pravilno uneseno!", "OK");
            }
            else if (string.IsNullOrWhiteSpace(this.Password.Text))
            {
                await DisplayAlert("Greška", "Morate unijeti lozinku", "OK");
            }
            else if (this.Password.Text != this.PasswordConfirmation.Text)
            {
                await DisplayAlert("Greška", "Lozinke moraju biti iste", "OK");
            }
            else if (this.Password.Text.Length < 4)
            {
                await DisplayAlert("Greška", "Lozinka mora sadržavati minimalno 4 karaktera!", "OK");
            }
            else
            {
                try
                {
                    model.Ime                  = this.Ime.Text;
                    model.Prezime              = this.Prezime.Text;
                    model.BrojTelefona         = this.BrojTelefona.Text;
                    model.Email                = this.Email.Text;
                    model.KorisnickoIme        = this.KorisnickoIme.Text;
                    model.Lozinka              = this.Password.Text;
                    model.PasswordConfirmation = this.PasswordConfirmation.Text;

                    await model.Registracija();
                }
                catch (Exception err)
                {
                    throw new Exception(err.Message);
                }
            }
        }
Пример #3
0
        private async void ButtonRegistracija_Clicked(object sender, EventArgs e)
        {
            bool duploime   = false;
            bool dupliemail = false;

            List <KupciVM> lista = await _serviceklijenti.Get <List <KupciVM> >(null);

            foreach (var item in lista)
            {
                if (item.KorisnickoIme.Equals(inputKorisnickoIme.Text) == true)
                {
                    duploime = true;
                }
                if (item.Email.Equals(inputEmail.Text) == true)
                {
                    dupliemail = true;
                }
            }

            if (validateRegistration() == true)
            {
                if (duploime == true)
                {
                    await DisplayAlert("Greska", "Korisnik sa tim korisnickim imenom je vec registrovan", "OK");

                    korisnickoImeError.Text      = "Korisnicko ime vec postoji!";
                    korisnickoImeError.IsVisible = true;
                }
                else if (dupliemail == true)
                {
                    await DisplayAlert("Greska", "Korisnik sa tim emailom je vec registrovan", "OK");

                    emailError.Text      = "Email vec postoji!";
                    emailError.IsVisible = true;
                }
                else
                {
                    await model.Registracija();
                }
            }
            else
            {
                await DisplayAlert("Greska", "Niste dobro unijeli neki od podataka", "OK");
            }
        }
Пример #4
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            bool ima = false;;

            if (string.IsNullOrEmpty(Ime.Text))
            {
                Ime.Placeholder      = "Obavezan unos!";
                Ime.PlaceholderColor = Color.Red;
                ima = true;
            }
            if (string.IsNullOrEmpty(Prezime.Text))
            {
                Prezime.Placeholder      = "Obavezan unos!";
                Prezime.PlaceholderColor = Color.Red;
                ima = true;
            }
            if (string.IsNullOrEmpty(KorisnickoIme.Text))
            {
                KorisnickoIme.Placeholder      = "Obavezan unos!";
                KorisnickoIme.PlaceholderColor = Color.Red;
                ima = true;
            }
            if (string.IsNullOrEmpty(Email.Text))
            {
                Email.Placeholder      = "Obavezan unos!";
                Email.PlaceholderColor = Color.Red;
                ima = true;
            }
            if (string.IsNullOrEmpty(Telefon.Text))
            {
                Telefon.Placeholder      = "Obavezan unos!";
                Telefon.PlaceholderColor = Color.Red;
                ima = true;
            }
            if (string.IsNullOrEmpty(Sifra.Text))
            {
                Sifra.Placeholder      = "Obavezan unos!";
                Sifra.PlaceholderColor = Color.Red;
                ima = true;
            }
            if (string.IsNullOrEmpty(SifraPotvrda.Text))
            {
                SifraPotvrda.Placeholder      = "Obavezan unos!";
                SifraPotvrda.PlaceholderColor = Color.Red;
                ima = true;
            }
            if (!ima)
            {
                bool uredu = true;
                if (await model.PostojiKorisnickoIme(KorisnickoIme.Text))
                {
                    await Application.Current.MainPage.DisplayAlert("Upozorenje", "Korisničko ime već postoji", "OK");

                    KorisnickoIme.Text = "Korisničko ime već postoji";
                    uredu = false;
                }
                if (await model.PostojiEmail(Email.Text))
                {
                    await Application.Current.MainPage.DisplayAlert("Upozorenje", "Email već postoji", "OK");

                    uredu = false;
                }
                if (SifraPotvrda.Text != Sifra.Text)
                {
                    await Application.Current.MainPage.DisplayAlert("Upozorenje", "Šifre se razlikuju", "OK");

                    uredu = false;
                }
                if (uredu)
                {
                    await model.Registracija();
                }
            }
        }
        private async void Button_Clicked(object sender, EventArgs e)
        {
            await model.Registracija();

            await Navigation.PushAsync(new LoginPage());
        }