Пример #1
0
        private async System.Threading.Tasks.Task SaveUserChangesAsync(String Email, String ForName, String SurName, long Phone, String Nationality)
        {
            User u = null;

            if (this.Intent.GetStringExtra("Action") == "Register")
            {
                u = new User();
            }
            else if (this.Intent.GetStringExtra("Action") == "Edit")
            {
                u = LDbConnection.GetUser();
            }
            u.ForName     = ForName;
            u.SurName     = SurName;
            u.Phone       = Phone;
            u.Email       = Email;
            u.Nationality = Nationality;
            if (await DbConnection.FetchUserEditAsync(u))
            {
                if (imageUri != null)
                {
                    await DbConnection.UploadImageUser
                        (this, imageUri, Email);

                    LDbConnection.InsertUser(this, await DbConnection.FetchUserAsync(Email));
                }
                else
                {
                    LDbConnection.InsertUser(await DbConnection.FetchUserAsync(Email));
                }
                var NxtAct = new Intent(this, typeof(StartActivity));
                StartActivity(NxtAct);
                Finish();
            }
        }
Пример #2
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;
            }
        }