Beispiel #1
0
        protected async void OnClickAsync()
        {
            TextView    email    = FindViewById <TextView>(Resource.Id.Email);
            TextView    password = FindViewById <TextView>(Resource.Id.Password);
            MobileLogin ml       = await DbConnection.FetchLoginAsync(email.Text, password.Text);

            if (ml.UserAndPasswordCorrect == true)
            {
                Login l = new Login
                {
                    Name     = email.Text,
                    Password = password.Text,
                    Typ      = ml.UserType
                };
                LDbConnection.InsertLogin(l);
                if (ml.UserType == "User")
                {
                    LDbConnection.InsertUser(this, await DbConnection.FetchUserAsync(email.Text));
                    LDbConnection.InsertUserExpos(await DbConnection.FetchUserExposAsync(LDbConnection.GetUser()));
                    //LDbConnection.InsertHistory(await DbConnection.FetchHistory(LDbConnection.GetUser()));
                }
                if (ml.UserType == "Company")
                {
                    LDbConnection.InsertCompany(this, await DbConnection.FetchCompanyAsync(email.Text));
                    LDbConnection.InsertUserExpos(await DbConnection.FetchUserExposAsync(LDbConnection.GetCompany()));
                    //LDbConnection.InsertHistory(await DbConnection.FetchHistory(LDbConnection.GetCompany()));
                }
                var NxtAct = new Intent(this, typeof(StartActivity));
                StartActivity(NxtAct);
                Finish();
            }
            else
            {
                if (TextUtils.IsEmpty(email.Text) || TextUtils.IsEmpty(password.Text))
                {
                    if (TextUtils.IsEmpty(email.Text))
                    {
                        email.RequestFocus();
                        email.SetError("Pole nie może być puste!", null);
                    }
                    if (TextUtils.IsEmpty(password.Text))
                    {
                        password.RequestFocus();
                        password.SetError("Pole nie może być puste!", null);
                    }
                }
                else if (ml.UserAndPasswordCorrect == false)
                {
                    email.RequestFocus();
                    email.SetError("Zły Email lub Hasło!", null);
                    password.RequestFocus();
                    password.SetError("Zły Email lub Hasło!", null);
                }
                return;
            }
        }