public async void CheckSignUp(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(fName.Text))
            {
                await DisplayAlert("Alert", "Required First Name", "OK");

                return;
            }
            if (string.IsNullOrEmpty(lName.Text))
            {
                await DisplayAlert("Alert", "Required Last Name", "OK");

                return;
            }
            if (string.IsNullOrEmpty(emailAddress.Text))
            {
                await DisplayAlert("Alert", "Required Email Address", "OK");

                return;
            }
            if (!BaseFunctions.IsValidEmail(emailAddress.Text))
            {
                await DisplayAlert("Alert", "Enter a valid email", "OK");

                return;
            }

            if (string.IsNullOrEmpty(password.Text))
            {
                await DisplayAlert("Alert", "Required Password", "OK");

                return;
            }
            if (string.IsNullOrEmpty(retypePassword.Text))
            {
                await DisplayAlert("Alert", "Please Re-type Password", "OK");

                return;
            }
            if (password.Text != retypePassword.Text)
            {
                await DisplayAlert("Alert", "Password doesn't match", "OK");

                return;
            }



            bool retry = false;

            do
            {
                try
                {
                    string     address = "http://www.myeventit.com/PHP/RegisterUser.php/";
                    var        client  = App.serverData.GetHttpClient();
                    ServerUser user    = new ServerUser();
                    user.userFirstName            = fName.Text;
                    user.userLastName             = lName.Text;
                    user.userEmail                = emailAddress.Text.ToLower();
                    user.userPrivacy              = "False";
                    user.userBookmarks            = new BookMark();
                    user.userBookmarks.speakers   = new List <string>();
                    user.userBookmarks.exhibitors = new List <string>();
                    user.userBookmarks.sponsors   = new List <string>();
                    user.userBookmarks.people     = new List <string>();
                    user.userBookmarks.session    = new List <string>();
                    user.userNotes                = new List <string>();
                    user.userAddress              = "";
                    user.userCompany              = "";
                    user.userDescription          = "";
                    user.userID         = "";
                    user.userImage      = "";
                    user.userPhone      = "";
                    user.userWebsite    = "";
                    user.userFacebook   = "";
                    user.userTwitter    = "";
                    user.userGplus      = "";
                    user.userLinkedIn   = "";
                    user.userCustomerID = new List <string>();
                    //user.userCustomerTokenList = new List<UserCard>();
                    var userString = JsonConvert.SerializeObject(user);

                    var postData = new List <KeyValuePair <string, string> >();
                    postData.Add(new KeyValuePair <string, string>("user", userString));
                    postData.Add(new KeyValuePair <string, string>("password", password.Text));
                    HttpContent         content = new FormUrlEncodedContent(postData);
                    CancellationToken   c       = new CancellationToken();
                    HttpResponseMessage result  = await client.PostAsync(address, content, c);

                    var isRegistered = await result.Content.ReadAsStringAsync();

                    if (isRegistered.ToString() == "exists")
                    {
                        await DisplayAlert("Alert", emailAddress.Text + " is already registered!!", "OK");

                        return;
                    }
                    else if (isRegistered.ToString() == "false")
                    {
                        await DisplayAlert("Alert", "Registration failed", "OK");

                        return;
                    }
                    else if (isRegistered.ToString() == "mailFail")
                    {
                        var k = await DisplayAlert("Alert", "Confirmation link sending failed", "Resend Confirmation Link", "OK");

                        if (k)
                        {
                            await App.serverData.ResendVerficationEmail(user.userEmail);
                        }
                        return;
                    }
                    else
                    {
                        await DisplayAlert("Success", "You are successfully registered. A Confirmation link will be sent to your email.", "Ok");

                        Application.Current.MainPage = new LoginPage();
                    }
                }
                catch (Exception ex)
                {
                    if (e.GetType() == typeof(System.Net.WebException))
                    {
                        retry = await App.Current.MainPage.DisplayAlert("Alert", "No internet connection found. Please check your internet.", "Retry", "Cancel");
                    }
                    else
                    {
                        retry = true;
                    }
                    if (!retry)
                    {
                        App.AppHaveInternet = false;
                        if (App.Current.MainPage.GetType() != typeof(LoginPage))
                        {
                            App.Current.MainPage = new LoginPage();
                        }
                    }
                }
            } while (retry);
        }
        public async void CheckLogin(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(username.Text))
            {
                await DisplayAlert("Alert", "Email Required", "OK");

                return;
            }
            if (!BaseFunctions.IsValidEmail(username.Text))
            {
                await DisplayAlert("Alert", "Enter a valid email", "OK");

                return;
            }
            if (string.IsNullOrEmpty(password.Text))
            {
                await DisplayAlert("Alert", "Password Required", "OK");

                return;
            }


            loadingText.Text    = "Checking with server...";
            loading.IsVisible   = true;
            loginForm.IsVisible = false;


            bool retry = false;

            do
            {
                try
                {
                    string address  = "http://www.myeventit.com/PHP/CheckUserLogin.php/";
                    var    client   = App.serverData.GetHttpClient();
                    var    postData = new List <KeyValuePair <string, string> >();
                    postData.Add(new KeyValuePair <string, string>("email", username.Text.ToLower()));
                    postData.Add(new KeyValuePair <string, string>("password", password.Text));
                    HttpContent         content = new FormUrlEncodedContent(postData);
                    CancellationToken   c       = new CancellationToken();
                    HttpResponseMessage result  = await client.PostAsync(address, content, c);

                    var isRegistered = await result.Content.ReadAsStringAsync();

                    if (isRegistered.ToString() != "false" && isRegistered.ToString() != "Inactive")
                    {
                        App.serverData.allDomainEvents = new List <DomainGroup>();
                        App.serverData.mei_user        = new UserProfile();
                        App.AppHaveInternet            = true;
                        App.userID = isRegistered.ToString();
                        App.SaveUser(this, null);
                        loadingText.Text    = "Loading your Profile...";
                        loading.IsVisible   = true;
                        loginForm.IsVisible = false;
                        await progressBar.ProgressTo(0.2, 250, Easing.Linear);

                        loadingText.Text = "Syncing registered Domains...";
                        var regDomains = await App.serverData.GetRegisteredDomain();

                        await progressBar.ProgressTo(0.4, 250, Easing.Linear);

                        loadingText.Text = "Syncing requested Domains...";
                        App.serverData.mei_user.currentUser = await App.serverData.GetUserWithID(App.userID);

                        App.serverData.CreateUserTokenList();
                        await App.serverData.GetRequestedDomains();

                        await progressBar.ProgressTo(0.6, 250, Easing.Linear);

                        loadingText.Text = "Syncing notes...";
                        App.serverData.SyncUserNotes();
                        await progressBar.ProgressTo(0.8, 250, Easing.Linear);

                        loadingText.Text = "Syncing shipping addresses...";
                        App.serverData.GetUserAddressList();
                        await progressBar.ProgressTo(0.9, 250, Easing.Linear);

                        loadingText.Text = "Syncing subscriptions...";
                        App.serverData.GetUserSubscriptions();
                        await progressBar.ProgressTo(1, 250, Easing.Linear);

                        App.serverData.AddPhone(CrossDeviceInfo.Current.Id, App.phoneID, App.userID);
                        Application.Current.MainPage = new HomeLayout();
                    }
                    else
                    {
                        if (isRegistered.ToString() == "false")
                        {
                            App.AppHaveInternet = true;
                            await DisplayAlert("Alert", "User email or Password is Invalid", "OK");

                            loading.IsVisible   = false;
                            loginForm.IsVisible = true;
                            return;
                        }
                        else
                        {
                            App.AppHaveInternet = true;
                            var k = await DisplayAlert("Alert", "Your account is still unverified.", "Resend Confirmation Link", "Ok");

                            if (k)
                            {
                                var j = await App.serverData.ResendVerficationEmail(username.Text);

                                if (j)
                                {
                                    await DisplayAlert("Alert", "Confirmation link will be sent to your email.", "Ok");
                                }
                            }
                            loading.IsVisible   = false;
                            loginForm.IsVisible = true;
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (ex.GetType() == typeof(System.Net.WebException))
                    {
                        retry = await App.Current.MainPage.DisplayAlert("Alert", "No internet connection found. Please check your internet.", "Retry", "Cancel");
                    }
                    else
                    {
                        retry = true;
                    }
                    if (!retry)
                    {
                        App.AppHaveInternet = false;
                        loading.IsVisible   = false;
                        loginForm.IsVisible = true;
                    }
                }
            } while (retry);
        }