Пример #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)
             {
                 if (res.admin == true)
                 {
                     return(2);
                 }
                 else
                 {
                     return(1);
                 }
             }
             else
             {
                 return(0);
             }
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(-1);
     }
 }
Пример #2
0
 public int dataInsert(UserLogins obj)
 {
     try
     {
         this.testCon();
         var setter = client.Set("Login/" + obj.login, obj);
         return(1);
     }
     catch
     {
         return(-1);
     }
 }
Пример #3
0
 public int checkLoginPossibility(UserLogins login)
 {
     try
     {
         this.testCon();
         var        resault = client.Get("Login/" + login.login);
         UserLogins res     = resault.ResultAs <UserLogins>();
         if (res == null)
         {
             return(1);
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(-1);
     }
 }
Пример #4
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();
                    StartActivity(typeof(Admin));
                }
                if (res == 1)
                {
                    GlobalVars.login = userLogin.Text;
                    Intent intent = new Intent(this, typeof(MainActivity));
                    intent.PutExtra("Login", "1");
                    Finish();
                    this.StartActivity(intent);
                }
                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;
            }));
        }