Exemplo n.º 1
0
        public async void SignIn(object obj)
        {
            try
            {
                LoadingMessage = "Signing In";
                IsBusy         = true;

                //check whether the user exists in Azure table
                //and get user id and save in local settings for single-sign on
                if (email != null && email.Contains("@"))
                {
                    BAMAppUser user = await ServiceLocator.AzureService.GetUserByEmail(email);

                    if (user != null)
                    {
                        if (user.Password == password)
                        {
                            Settings.UserId = user.Id;
                            //for home page master page labels (name, avatar) the following are stored in settings
                            Settings.Avatar = user.Avatar;
                            Settings.Name   = user.Name;
                            await TakeToHomePage();
                        }
                        else
                        {
                            await signInPage.DisplayAlert("Sorry", "Invalid password!", "Try again");
                        }
                    }
                    else
                    {
                        await signInPage.DisplayAlert("Sorry", "Invalid email id!", "Try again");
                    }
                }
                else
                {
                    await signInPage.DisplayAlert("Sorry", "Invalid email id!", "Enter correct email id");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("OH NO!" + ex);
            }
            finally
            {
                IsBusy = false;
            }
        }