Example #1
0
        async void Login()
        {
            App.UserDialogService.ShowLoading("Signing in...");
            await Task.Delay(3000);

            User u = new User();

            u.Email    = UserName;
            u.Password = Password;
            bool success = await Acc.LoginAsync(UserName, Password);

            if (success)
            {
                App.UserDialogService.HideLoading();
                if (Settings.IsFirstRun)
                {
                    Settings.IsFirstRun = false;
                    UserName            = string.Empty;
                    Password            = string.Empty;
                    OnPropertyChanged("UserName");
                    OnPropertyChanged("Password");
                    await Navi.PopModal();

                    await Navi.PushModal(PageFac.GetPage(Pages.Guide));
                }
                else
                {
                    await Navi.PopModal();
                }
            }
            else
            {
                App.UserDialogService.HideLoading();
                await App.UserDialogService.AlertAsync("We could not log you in at this time, please try again");
            }
        }
Example #2
0
        async Task <bool> CreateUser()
        {
            var user = new User
            {
                Email       = Email,
                FirstName   = FirstName,
                LastName    = LastName,
                PhoneNumber = Phone,
                Password    = Password,
                Status      = new UserStatus {
                    ActiveStatus = Status.Active, LastUpdated = DateTime.UtcNow
                }
            };

            UserResponse response = await Acc.RegisterAsync(user, null);

            if (response.success)
            {
                if (await Acc.LoginAsync(Email, Password))
                {
                    App.ThisUser = user;
                    return(true);
                }
                else
                {
                    await App.UserDialogService.AlertAsync("Can't login with user " + Email, "Error", "OK");
                }
            }
            else
            {
                await App.UserDialogService.AlertAsync(response.errors != null?response.errors.First() : "Not sure what happened there, please try again", "Oops!", "Ok");
            }


            return(false);
        }