Exemple #1
0
        private async Task Login()
        {
            UserModel um = null;

            StaticMethods.ShowLoader();
            Task.Factory.StartNew(
                // tasks allow you to use the lambda syntax to pass wor
                () =>
            {
                um          = new UserModel();
                um.name     = txtUsername.Text;
                um.password = txtPass.Text;
                model       = WebService.Login(um);
            }).ContinueWith(async
                            t =>
            {
                if (model != null)
                {
                    StaticDataModel.userId = Convert.ToInt32(model.user_id);

                    StaticMethods.SaveLocalData(model);

                    StaticMethods.ShowToast("Login successfully");
                    StaticDataModel.IsAnonymousLogin = false;
                    App.Current.MainPage             = new NavigationPage(new MainPage());
                }
                else
                {
                    //StaticMethods.ShowToast(um.responseMessage);
                }

                StaticMethods.DismissLoader();
            }, TaskScheduler.FromCurrentSynchronizationContext()
                            );
        }
Exemple #2
0
        private async Task SignUp(User user)
        {
            UserModel um = null;

            StaticMethods.ShowLoader();
            Task.Factory.StartNew(
                // tasks allow you to use the lambda syntax to pass wor
                () =>
            {
                um = new UserModel();
                um.is_social_signup = 1;
                um.email            = user.Email;
                if (user.Name != null)
                {
                    um.name = user.Name;
                }
                else
                {
                    um.name = user.First_Name + "" + user.Last_Name;
                }
                um.password = "******";
                model       = WebService.SignUp(um);
            }).ContinueWith(async
                            t =>
            {
                if (model != null)
                {
                    StaticDataModel.userId = Convert.ToInt32(model.user_id);
                    StaticMethods.SaveLocalData(model);

                    StaticMethods.ShowToast("Login successfully");
                    StaticDataModel.IsAnonymousLogin = false;
                    App.Current.MainPage             = new NavigationPage(new MainPage());
                }
                else
                {
                    StaticMethods.ShowToast("User already exists.");
                }

                StaticMethods.DismissLoader();
            }, TaskScheduler.FromCurrentSynchronizationContext()
                            );
        }