// private async Task InsertGuestInfo() {


           

      //  }

        private async void sbmtbutton_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(nametext.Text) ||String.IsNullOrWhiteSpace(usernametext.Text) || String.IsNullOrWhiteSpace(passwordtext.Password) || String.IsNullOrWhiteSpace(contacttext.Text) || String.IsNullOrWhiteSpace(emailtext.Text) || String.IsNullOrWhiteSpace(contacttext.Text))
            {
                MessageDialog msgBox = new MessageDialog("Fill the all fields!");
                await msgBox.ShowAsync();
                this.Frame.Navigate(typeof(MainPage), null);
            }
            else
            {
                Guest guest = new Guest();
                guest.name = nametext.Text;
               // guest.UserName = usernametext.Text;
                guest.password = passwordtext.Password;
                guest.contact = Int32.Parse(contacttext.Text);
                guest.email = emailtext.Text;
                guest.address = addresstext.Text;
               // guest.deviceId = loginpage.GetDeviceId();

                try
                {
                    await guestTable.InsertAsync(guest);
                }
                catch (MobileServiceInvalidOperationException ex)
                {
                    await new MessageDialog(ex.Message, "Could not connect to server").ShowAsync();
                    

                }
                MessageDialog msg = new MessageDialog("User registration complete!!!");
                await msg.ShowAsync();
                this.Frame.Navigate(typeof(loginpage), null);
            }

        }
        private void ListItems_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            Guest selectedguest = ((sender as ListView).SelectedItem as Guest);
            
            if (selectedguest != null)
            {
                
                System.Diagnostics.Debug.WriteLine("Clicked Line is :" + selectedguest.name);
                inviteList.Items.Add(selectedguest.name);
                Guest guest = new Guest();
                guest.name = selectedguest.name;
                invitees.Add(guest);
                
            }
            else
            {
                MessageDialog msgBox = new MessageDialog("No match found");
            }

            
        }
        private static async Task AddFacebookUser(string accessToken)
        {
            //get fbuser info
            var httpClientfb = new HttpClient();
            var responsefb = await httpClientfb.GetStringAsync(new Uri("https://graph.facebook.com/me?fields=name,email&access_token=" + accessToken));
            var value = JsonValue.Parse(responsefb).GetObject();
            var facebookUserName = value.GetNamedString("name");
            var facebookemail = value.GetNamedString("email");

            //cache the name of signed in user
            var localuserSettings = ApplicationData.Current.LocalSettings;
            localuserSettings.Values["name"] = facebookUserName;

            System.Diagnostics.Debug.WriteLine("azure user id : " + azureuserid);
            /**
               Save guest into guest table**/
            Guest guest = new Guest();
            guest.name = facebookUserName;
            guest.userid = azureuserid;
            guest.email = facebookemail;

            try
            {
                await guestTable.InsertAsync(guest);
            }
            catch (MobileServiceInvalidOperationException ex)
            {
                // await new MessageDialog(ex.Message, "Could not connect to server").ShowAsync();
                System.Diagnostics.Debug.WriteLine(ex.Message, "Could not connect to server");

            }

        }