예제 #1
0
 public int checkLogin(UserLogins login)
 {
     try
     {
         this.testCon();
         var        resault = client.Get("Login/" + login.login);
         UserLogins res     = resault.ResultAs <UserLogins>();
         if (res != null)
         {
             if (login.login == res.login && login.userPassword == res.userPassword)
             {
                 return(1);
             }
             else
             {
                 return(0);
             }
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(-1);
     }
 }
예제 #2
0
        private async Task LoginCheck()
        {
            await Task.Run(() => this.RunOnUiThread(() =>
            {
                progressBar.Visibility = ViewStates.Visible;
            }));

            UserLogins login = new UserLogins()
            {
                login        = userLogin.Text,
                userPassword = userPassword.Text
            };
            FireBaseConnector connection = new FireBaseConnector();

            if (login.login.Length > 0 && login.userPassword.Length > 0)
            {
                var res = connection.checkLogin(login);
                await Task.Run(() => this.RunOnUiThread(() =>
                {
                    progressBar.Visibility = ViewStates.Invisible;
                }));

                if (res == 2)
                {
                    Finish();
                }
                if (res == 1)
                {
                    StartActivity(typeof(MainActivity));
                    Finish();
                }
                if (!connection.connection)
                {
                    Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this);
                    alertDialog.SetTitle(GetString(Resource.String.noInternetConnection));
                    alertDialog.SetIcon(Resource.Drawable.ic5c_192x192);
                    alertDialog.SetMessage(GetString(Resource.String.checkConnection));
                    alertDialog.SetNeutralButton(GetString(Resource.String.OKbutton), delegate
                    {
                        alertDialog.Dispose();
                    });
                    alertDialog.Show();
                }
                if (res == 0)
                {
                    Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this);
                    alertDialog.SetTitle(GetString(Resource.String.loginError));
                    alertDialog.SetIcon(Resource.Drawable.ic4c_192x192);
                    alertDialog.SetMessage(GetString(Resource.String.correctLogin));
                    alertDialog.SetNeutralButton(GetString(Resource.String.OKbutton), delegate
                    {
                        alertDialog.Dispose();
                    });
                    alertDialog.Show();
                }
            }
            else
            {
                Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this);
                alertDialog.SetTitle(GetString(Resource.String.loginError));
                alertDialog.SetIcon(Resource.Drawable.ic4c_192x192);
                alertDialog.SetMessage(GetString(Resource.String.emptyLogin));
                alertDialog.SetNeutralButton(GetString(Resource.String.OKbutton), delegate
                {
                    alertDialog.Dispose();
                });
                alertDialog.Show();
            }
            await Task.Run(() => this.RunOnUiThread(() =>
            {
                progressBar.Visibility = ViewStates.Invisible;
            }));
        }