public OCustomer UpdateCustomer(string accessToken, Customer objCustomer)
        {
            OCustomer obj_OCustomer = new OCustomer();

            try
            {
                string baseUrl = Convert.ToString(App.Current.Properties["BaseURL"]);
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(baseUrl);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    // Add the Authorization header with the AccessToken.
                    client.DefaultRequestHeaders.Add("Authorization", "bearer  " + accessToken);
                    // create the URL string.
                    string url = "api/InstaConsumer/UpdateCustomer";
                    // make the request

                    var json    = JsonConvert.SerializeObject(objCustomer);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = client.PostAsync(url, content).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        string jsonString = response.Content.ReadAsStringAsync().Result;
                        if (jsonString != null)
                        {
                            APIResponse apiResult = JsonConvert.DeserializeObject <APIResponse>(jsonString);

                            if (apiResult.Result)
                            {
                                obj_OCustomer = JsonConvert.DeserializeObject <OCustomer>(Convert.ToString(apiResult.Object));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(obj_OCustomer);
        }
        //Floating Lable Code End
        public MyProfile(OCustomer customer)
        {
            InitializeComponent();
            ShowLoading(true);
            dal_Customer        = new DALCustomer();
            CustomerID          = customer.CustomerID;
            Gender_static       = customer.Gender;
            txtName.Text        = customer.Name;
            txtPhoneNumber.Text = customer.PhoneNumber;
            txtEmail.Text       = customer.Email;
            imgProfile.Source   = customer.ProfileImage == null ? "profilepic.png" :
                                  ImageSource.FromStream(() => new MemoryStream(ByteArrayCompressionUtility.Decompress(customer.ProfileImage)));

            imgCameraByteData = customer.ProfileImage == null ? null :
                                new MemoryStream(ByteArrayCompressionUtility.Decompress(customer.ProfileImage)).ToArray();

            if (customer.YearOfBirth != 0)
            {
                txtYearOfBirth.Text = Convert.ToString(customer.YearOfBirth);
            }
            else
            {
                txtYearOfBirth.Text = "";
            }
            ShowLoading(false);

            //Floating Lable Code Start
            lblName.TranslationX = lblPhoneNumber.TranslationX = lblEmail.TranslationX = lblYear.TranslationX = 10;
            lblName.FontSize     = lblPhoneNumber.FontSize = lblEmail.FontSize = lblYear.FontSize = _placeholderFontSize;
            lblName.TextColor    = lblPhoneNumber.TextColor = lblEmail.TextColor = lblYear.TextColor = Color.Gray;

            if (string.IsNullOrEmpty(txtName.Text))
            {
                TransitionToPlaceholder(true);
            }
            else
            {
                TransitionToTitle(true);
            }
            if (string.IsNullOrEmpty(txtPhoneNumber.Text))
            {
                TransitionToPlaceholder_PhoneNo(true);
            }
            else
            {
                TransitionToTitle_PhoneNo(true);
            }
            if (string.IsNullOrEmpty(txtEmail.Text))
            {
                TransitionToPlaceholder_Email(true);
            }
            else
            {
                TransitionToTitle_Email(true);
            }
            if (string.IsNullOrEmpty(txtYearOfBirth.Text))
            {
                TransitionToPlaceholder_YearofBirth(true);
            }
            else
            {
                TransitionToTitle_YearofBirth(true);
            }

            txtName.Focus();
            //Floating Lable Code End
        }
        private async void btn_UpdateClicked(object sender, EventArgs e)
        {
            IsOnline = VerifyInternet();

            if (IsOnline)
            {
                btnUpdate.IsVisible = false;
                ShowLoading(true);

                try
                {
                    if (txtName.Text == "" || txtName.Text == null)
                    {
                        btnUpdate.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "Please enter your Name", "Ok");
                        return;
                    }

                    var regexName = new Regex("^[a-z A-Z]*$");
                    if (!regexName.IsMatch(txtName.Text.Trim()))
                    {
                        btnUpdate.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "Please enter only alphabets for Name", "Ok");
                        return;
                    }

                    if (txtPhoneNumber.Text == "" || txtPhoneNumber.Text == null)
                    {
                        btnUpdate.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "Please enter your Phone Number", "Ok");
                        return;
                    }

                    if (txtEmail.Text == "" || txtEmail.Text == null)
                    {
                        btnUpdate.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "Please enter your Email", "Ok");
                        return;
                    }

                    if (txtName.Text.Length >= 3 && txtName.Text.Length <= 20)
                    {
                        if (txtEmail.Text != "" && txtEmail.Text != null)
                        {
                            if (!RegexUtilities.IsEmailValid(txtEmail.Text.Trim()))
                            {
                                btnUpdate.IsVisible = true;
                                ShowLoading(false);
                                DisplayAlert("", "Please enter valid Email", "Ok");
                                return;
                            }
                        }
                        Customer objCustomer = new Customer();
                        objCustomer.CustomerID  = CustomerID;
                        objCustomer.Name        = txtName.Text.Trim();
                        objCustomer.Email       = txtEmail.Text == null || txtEmail.Text == "" ? "" : txtEmail.Text.Trim();
                        objCustomer.PhoneNumber = txtPhoneNumber.Text.Trim();
                        objCustomer.Gender      = Gender_static;

                        if (imgCameraByteData != null)
                        {
                            objCustomer.ProfileImage = ByteArrayCompressionUtility.Compress(imgCameraByteData);
                        }

                        if (App.Current.Properties.ContainsKey("RefreshedToken"))
                        {
                            btnUpdate.IsVisible  = true;
                            objCustomer.DeviceID = Convert.ToString(App.Current.Properties["RefreshedToken"]);
                        }
                        else
                        {
                            btnUpdate.IsVisible  = true;
                            objCustomer.DeviceID = "";
                        }

                        if (txtYearOfBirth.Text != "" && txtYearOfBirth.Text != null)
                        {
                            if (Convert.ToInt32(txtYearOfBirth.Text.Trim()) > 1900)
                            {
                                DateTime dateOfBirth = new DateTime(Convert.ToInt32(txtYearOfBirth.Text.Trim()), DateTime.Now.Month, 1);
                                objCustomer.DateOfBirth = dateOfBirth;
                                objCustomer.Age         = Convert.ToInt32(DateTime.Now.Year) - Convert.ToInt32(txtYearOfBirth.Text.Trim());
                            }
                            else
                            {
                                btnUpdate.IsVisible = true;
                                ShowLoading(false);
                                DisplayAlert("", "Only people born after 1900 please! Enter your Year of Birth", "Ok");
                                return;
                            }
                        }
                        else
                        {
                            objCustomer.DateOfBirth = null;
                            objCustomer.Age         = 0;
                        }

                        if (App.Current.Properties.ContainsKey("apitoken"))
                        {
                            var json    = JsonConvert.SerializeObject(objCustomer);
                            var content = new StringContent(json, Encoding.UTF8, "application/json");
                            dal_Customer = new DALCustomer();
                            OCustomer resultObj = new OCustomer();

                            await Task.Run(() =>
                            {
                                resultObj = dal_Customer.UpdateCustomer(Convert.ToString(App.Current.Properties["apitoken"]), objCustomer);
                            });

                            if (resultObj.CustomerID != 0)
                            {
                                App.Current.Properties["UserName"]     = txtName.Text.Trim();
                                App.Current.Properties["PhoneNumber"]  = txtPhoneNumber.Text.Trim();
                                App.Current.Properties["Email"]        = txtEmail.Text.Trim();
                                App.Current.Properties["CustomerID"]   = resultObj.CustomerID;
                                App.Current.Properties["ProfileImage"] = resultObj.ProfileImage;
                                await Application.Current.SavePropertiesAsync();

                                int CustomerID = resultObj.CustomerID;
                                App.Current.Properties["CustomerID"] = CustomerID;

                                btnUpdate.IsVisible = true;
                                ShowLoading(false);
                                await Navigation.PushAsync(new Home(null, CustomerID));
                            }
                            else
                            {
                                btnUpdate.IsVisible = true;
                                ShowLoading(false);
                                DisplayAlert("Failed - UpdateCustomer", "Update Customer Failed", "Ok");
                            }
                        }
                        else
                        {
                            btnUpdate.IsVisible = true;
                            ShowLoading(false);
                        }
                    }
                    else
                    {
                        btnUpdate.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "Name must be atleast 3 characters and maximum 20 characters", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    btnUpdate.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("Failed - ", "Failed To Update Details", "Ok");
                }
            }
            else
            {
                await DisplayAlert("", "Please check your network connectivity", "Ok");

                return;
            }
        }
        private async void btn_SendOTPClicked(object sender, EventArgs e)
        {
            btnSendOTP.IsVisible = false;
            ShowLoading(true);

            if (txtName.Text == "" || txtName.Text == null)
            {
                btnSendOTP.IsVisible = true;
                ShowLoading(false);
                DisplayAlert("", "Please enter your Name", "Ok");
                return;
            }

            var regexName = new Regex("^[a-z A-Z]*$");

            if (!regexName.IsMatch(txtName.Text.Trim()))
            {
                btnSendOTP.IsVisible = true;
                ShowLoading(false);
                DisplayAlert("", "Please enter only alphabets for Name", "Ok");
                return;
            }

            if (txtPhoneNumber.Text == "" || txtPhoneNumber.Text == null)
            {
                btnSendOTP.IsVisible = true;
                ShowLoading(false);
                DisplayAlert("", "Please enter your Phone Number", "Ok");
                return;
            }

            if (txtEmail.Text == "" || txtEmail.Text == null)
            {
                btnSendOTP.IsVisible = true;
                ShowLoading(false);
                DisplayAlert("", "Please enter your Email", "Ok");
                return;
            }

            if (txtName.Text.Length >= 3 && txtName.Text.Length <= 20)
            {
                if (txtEmail.Text != "" && txtEmail.Text != null)
                {
                    if (!RegexUtilities.IsEmailValid(txtEmail.Text.Trim()))
                    {
                        btnSendOTP.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "Please enter valid Email", "Ok");
                        return;
                    }
                }

                Customer objCustomer = new Customer();
                objCustomer.CustomerID  = CustomerID;
                objCustomer.Name        = txtName.Text.Trim();
                objCustomer.Email       = txtEmail.Text == null || txtEmail.Text == "" ? "" : txtEmail.Text.Trim();
                objCustomer.PhoneNumber = txtPhoneNumber.Text.Trim();
                objCustomer.Gender      = Gender_static;

                if (App.Current.Properties.ContainsKey("RefreshedToken"))
                {
                    btnSendOTP.IsVisible = true;
                    objCustomer.DeviceID = Convert.ToString(App.Current.Properties["RefreshedToken"]);
                }
                else
                {
                    btnSendOTP.IsVisible = true;
                    objCustomer.DeviceID = "";
                }

                if (txtYearOfBirth.Text != "" && txtYearOfBirth.Text != null)
                {
                    if (Convert.ToInt32(txtYearOfBirth.Text.Trim()) > 1900)
                    {
                        DateTime dateOfBirth = new DateTime(Convert.ToInt32(txtYearOfBirth.Text.Trim()), DateTime.Now.Month, 1);
                        objCustomer.DateOfBirth = dateOfBirth;
                        objCustomer.Age         = Convert.ToInt32(DateTime.Now.Year) - Convert.ToInt32(txtYearOfBirth.Text.Trim());
                    }
                    else
                    {
                        btnSendOTP.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "Only people born after 1900 please! Enter your Year of Birth", "Ok");
                        return;
                    }
                }
                else
                {
                    objCustomer.DateOfBirth = null;
                    objCustomer.Age         = 0;
                }

                if (App.Current.Properties.ContainsKey("apitoken"))
                {
                    var json    = JsonConvert.SerializeObject(objCustomer);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    dal_Customer = new DALCustomer();
                    OCustomer resultObj = dal_Customer.InsertCustomer(Convert.ToString(App.Current.Properties["apitoken"]), objCustomer);

                    if (resultObj.CustomerID != 0)
                    {
                        btnSendOTP.IsVisible = true;
                        ShowLoading(false);
                        await Application.Current.SavePropertiesAsync();

                        await Navigation.PushAsync(new VerifyOTP(txtPhoneNumber.Text, resultObj.CustomerID, "NEW", txtName.Text));
                    }
                    else
                    {
                        btnSendOTP.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("Failed - InsertCustomer", "Insert customer failed", "Ok");
                    }
                }
                else
                {
                    btnSendOTP.IsVisible = true;
                    ShowLoading(false);
                }
            }
            else
            {
                btnSendOTP.IsVisible = true;
                ShowLoading(false);
                DisplayAlert("", "Name must be atleast 3 characters and maximum 20 characters", "Ok");
            }
        }
        private async void btn_ProceedClicked(object sender, EventArgs e)
        {
            btnProceed.IsVisible = false;
            ShowLoading(true);
            IsOnline = VerifyInternet();
            if (IsOnline)
            {
                if (txtPhoneNumber.Text != "" && txtPhoneNumber.Text != null)
                {
                    if (txtPhoneNumber.Text.Length != 10)
                    {
                        btnProceed.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "Please enter valid Phone Number", "Ok");
                        return;
                    }

                    Customer objCustomer = new Customer();
                    objCustomer.PhoneNumber = txtPhoneNumber.Text;

                    // Remove Code

                    using (HttpClient client = new HttpClient())
                    {
                        client.BaseAddress = new Uri(Convert.ToString(App.Current.Properties["BaseURL"]));
                        // We want the response to be JSON.
                        client.DefaultRequestHeaders.Accept.Clear();
                        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                        List <KeyValuePair <string, string> > postData = new List <KeyValuePair <string, string> >();
                        postData.Add(new KeyValuePair <string, string>("grant_type", "password"));
                        postData.Add(new KeyValuePair <string, string>("username", "Kiran"));
                        postData.Add(new KeyValuePair <string, string>("password", "1234"));
                        FormUrlEncodedContent content = new FormUrlEncodedContent(postData);
                        // Post to the Server and parse the response.
                        var response = client.PostAsync("Token", content).Result;
                        if (response.IsSuccessStatusCode)
                        {
                            var        jsonString   = response.Content.ReadAsStringAsync();
                            OAuthToken responseData = JsonConvert.DeserializeObject <OAuthToken>(jsonString.Result);
                            string     Access_Token = responseData.access_token;
                            App.Current.Properties["apitoken"] = Access_Token;
                        }
                    }

                    // Remove Code

                    if (App.Current.Properties.ContainsKey("apitoken"))
                    {
                        var json    = JsonConvert.SerializeObject(objCustomer);
                        var content = new StringContent(json, Encoding.UTF8, "application/json");
                        dal_Customer = new DALCustomer();
                        OCustomer resultObj = dal_Customer.ValidateCustomer(Convert.ToString(App.Current.Properties["apitoken"]), objCustomer);

                        if (resultObj.CustomerID != 0)
                        {
                            btnProceed.IsVisible = true;
                            ShowLoading(false);
                            await Navigation.PushAsync(new VerifyOTP(txtPhoneNumber.Text, resultObj.CustomerID, "EXISTING", resultObj.Name));
                        }
                        else
                        {
                            btnProceed.IsVisible = true;
                            ShowLoading(false);
                            await Navigation.PushAsync(new SignUp(resultObj.CustomerID, txtPhoneNumber.Text));
                        }
                    }
                    else
                    {
                        btnProceed.IsVisible = true;
                        ShowLoading(false);
                    }
                }
                else
                {
                    btnProceed.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter your Phone Number", "Ok");
                }
            }
            else
            {
                await DisplayAlert("", "Please check your network connectivity", "Ok");

                return;
            }
        }