예제 #1
0
        private async void BtnLogin_Clicked(object sender, EventArgs e)
        {
            activityControl.MakeVisible(ActivityLayout, activity);
            btnLogin.IsEnabled = false;
            User            logonUser = new User();
            string          email     = entryEmail.Text;
            string          password  = entryPassword.Text;
            LoginValidation validate  = new LoginValidation();

            if (validate.ReturnSituation(entryEmail.Text, entryPassword.Text) != "Success")
            {
                activityControl.MakeUnVisible(ActivityLayout, activity);
                btnLogin.IsEnabled = true;
                await DisplayAlert("Uyarı", validate.ReturnSituation(entryEmail.Text, entryPassword.Text), "OK");
            }
            else
            {
                try
                {
                    logonUser = await service.Login(email, password);

                    if (logonUser != null)
                    {
                        CrossSecureStorage.Current.SetValue("loggedUserId", logonUser.Id.ToString());
                        CrossSecureStorage.Current.SetValue("loggedUserEmail", logonUser.Email);
                        CrossSecureStorage.Current.SetValue("loggedUserPassword", logonUser.Password);
                        Application.Current.MainPage = new NavigationPage(new IndexPageMain());
                    }
                    else
                    {
                        activityControl.MakeUnVisible(ActivityLayout, activity);
                        btnLogin.IsEnabled = true;
                        await DisplayAlert("Uyarı", "Kullanıcı adı veya şifre hatalı", "OK");
                    }
                }
                catch (Exception ex)
                {
                    activityControl.MakeUnVisible(ActivityLayout, activity);
                    btnLogin.IsEnabled = true;
                    await DisplayAlert("Uyarı", "Kullanıcı adı veya şifre hatalı", "OK");
                }
            }
        }