Beispiel #1
0
        async Task Login()
        {
            IsBusy = true;
            APIService.Username = Username;
            APIService.Password = Password;

            var request = new UserAuthenticationRequest()
            {
                Username = APIService.Username,
                Password = APIService.Password
            };

            var user = await userService.Authenticate(request);

            if (user != null)
            {
                Application.Current.MainPage = new MainPage();
                SignedInUser.User            = user;
                new LikeHelper();
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Enter a Valid Username and Password!", "OK");
            }
        }
Beispiel #2
0
        private async void btnLogin_Click(object sender, EventArgs e)
        {
            loader1.Visible = true;

            APIService.Username = txtUsername.Text;
            APIService.Password = txtPassword.Text;

            try
            {
                var request = new AuthenticateRequest()
                {
                    Username = APIService.Username,
                    Password = APIService.Password
                };

                var response = await _service.Authenticate(request);

                if (response == null)
                {
                    throw new Exception();
                }

                frmIndex frm = new frmIndex();
                frm.Show();
                loader1.Visible = false;
                frm.FormClosed += new FormClosedEventHandler(frmLogin_FormClosed);
                Hide();
            }
            catch (Exception)
            {
                loader1.Visible = false;
                MessageBox.Show("Podaci nisu ispravni", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        async Task SignIn()
        {
            IsBusy = true;
            APIService.Username = Username;
            APIService.Password = Password;
            var request = new UserAuthenticationRequest()
            {
                Username = APIService.Username,
                Password = APIService.Password
            };

            var user = await _service.Authenticate(request);

            if (user != null)
            {
                var userRole = user.UserRoles.FirstOrDefault(i => i.Role.Name == "User");
                if (userRole != null)
                {
                    Application.Current.MainPage = new MainPage();
                    SignedInUserHelper.User      = user;
                    new FavouritesHelper();
                }
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Wrong Username or Password", "OK");
            }
        }
Beispiel #4
0
        async Task Login()
        {
            try
            {
                IsBusy = true;
                APIService.Username = KorisnickoIme;
                APIService.Password = Lozinka;
                var request = new AuthenticateRequest()
                {
                    Username = APIService.Username,
                    Password = APIService.Password
                };
                var user = await _korisnik.Authenticate(request);

                if (user == null)
                {
                    throw new Exception("Pogrešno korisničko ime ili lozinka");
                }
                Application.Current.MainPage = new MainPage();
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Niste autentificirani", ex.Message, "OK");
            }
        }
        async Task Login()
        {
            IsBusy = true;
            bool userIsServiser = false;
            bool userIsKorisnik = false;

            try
            {
                KorisniciModel korisnik = await _service.Authenticate <KorisniciModel>(Username, Password);

                if (korisnik != null)
                {
                    foreach (var item in korisnik.KorisniciUloge)
                    {
                        if (item.Uloga.Naziv == "serviser")
                        {
                            userIsServiser        = true;
                            APIService.Username   = Username;
                            APIService.Password   = Password;
                            APIService.KorisnikId = item.KorisnikId;
                        }
                        else if (item.Uloga.Naziv == "korisnik")
                        {
                            userIsKorisnik        = true;
                            APIService.Username   = Username;
                            APIService.Password   = Password;
                            APIService.KorisnikId = item.KorisnikId;
                        }
                    }
                    if (userIsServiser)
                    {
                        Application.Current.MainPage = new AppShellServiser();
                    }
                    else if (userIsKorisnik)
                    {
                        Application.Current.MainPage = new AppShell();
                    }
                    else
                    {
                        await Application.Current.MainPage.DisplayAlert("Greška", "Korisnik mora biti pod Serviser ili Korisnik rolom", "OK");
                    }
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Greška", "Pogrešan Username ili Password", "OK");
                }
            }
            catch
            {
            }
        }
Beispiel #6
0
        async Task Login()
        {
            IsBusy = true;
            APIService.Username = Username;
            APIService.Password = Password;

            try
            {
                var request = new AuthenticateRequest()
                {
                    Username = APIService.Username,
                    Password = APIService.Password
                };

                var result = await _service.Authenticate(request);

                if (result != null)
                {
                    var customer = await new APIService("Customer/GetByAccountId").GetById <Customer>(result.Id);
                    APIService.Client = customer;
                    IsBusy            = false;
                    var mainPage = new MainPage();
                    await mainPage.NavigateFromMenu((int)MenuItemType.Pocetak);

                    Application.Current.MainPage = mainPage;
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Podaci nisu ispravni", "OK");
            }

            IsBusy = false;
        }
Beispiel #7
0
        private async void button3_Click(object sender, EventArgs e)
        {
            APIService.Username = txtUsrName.Text;
            APIService.Password = txtPass.Text;

            var request = new UserAuthenticationRequest()
            {
                Username = APIService.Username,
                Password = APIService.Password
            };

            var user = await userService.Authenticate(request);

            if (user != null)
            {
                LoadPanel(user);
                this.Hide();
            }
            else
            {
                MessageBox.Show("Wrong Username Or Password!");
            }
        }
Beispiel #8
0
        private async void btnSignIn_ClickAsync(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                APIService.Username = txtUsername.Text;
                APIService.Password = txtPassword.Text;
                var request = new UserAuthenticationRequest()
                {
                    Username = APIService.Username,
                    Password = APIService.Password
                };

                var user = await _service.Authenticate(request);

                if (user != null)
                {
                    LoadPanel(user);
                }
                else
                {
                    errorProviderPassword.SetError(txtPassword, "Wrong Password");
                }
            }
        }