public async Task <CustomerApiData> FetchCustomerList(string storecust_id)
        {
            var    app         = Application.Current as App;
            string AccessKey   = app.UserKey;
            string PhoneNumber = app.UserPhoneNumber;
            string baseUrl     = "https://getpymobileapp.azurewebsites.net/api/v2/merchant/";
            string url         = string.Format("{0}{1}", baseUrl, "StoreCustomer_Details");

            using (HttpClient Webclient = new HttpClient())
            {
                var uri = new Uri(url);
                Dictionary <string, dynamic> payload = new Dictionary <string, dynamic>();
                payload.Add("storecustomer_id", storecust_id);
                payload.Add("phone_number", PhoneNumber);
                payload.Add("access_key", AccessKey);

                var json     = JsonConvert.SerializeObject(payload);
                var content  = new StringContent(json, Encoding.UTF8, "application/json");
                var response = await Webclient.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    var rcontent = await response.Content.ReadAsStringAsync();

                    try
                    {
                        CustomerApiResponse customData = JsonConvert.DeserializeObject <CustomerApiResponse>(rcontent);
                        Console.WriteLine("Response of custdetails Status is : " + customData.Status);
                        if (customData.Status.ToLower() != "success")
                        {
                            System.Diagnostics.Debug.WriteLine("[BuildRequestNDisplay] Received non-success " + customData.Status);
                            System.Diagnostics.Debug.WriteLine("[BuildRequestNDisplay] Received Response: " + content);
                            return(null);
                        }
                        ResponseData = customData.Data;
                        return(ResponseData);
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine("Error in customer API " + e.Message);
                    }
                }
                return(null);
            }
        }
        public async Task <ObservableCollection <CustomerInvoiceDatum> > ExecuteLoadItemsCommand(string menuPage)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    ObservableCollection <CustomerInvoiceDatum> tempItems = new ObservableCollection <CustomerInvoiceDatum>();
                    if (OrderList.Count == 0)
                    {
                        pageNumber = 1;
                    }
                    int frameSize = 10;
                    var items     = await OrderApiService.Instance.RefreshOrderList((frameSize / 2), pageNumber, menuPage);

                    if (!(items.CustomerInvoiceData.Count == 0 && items.WooCommerceOrders.Count == 0))
                    {
                        ListFooterText = null;
                        pageNumber++;
                        foreach (var item in items.CustomerInvoiceData)
                        {
                            try
                            {
                                CustomerInfo = new CustomerDetails();
                                AddressInfo  = new AddressDetails();
                                CustomerApiData CustData = await CustomerApiService.Instance.FetchCustomerList(item.StoreCustomerId);

                                AddressApiData AddressItem = await AddressApiService.Instance.RefreshAddressList(item.DeliverAddressId);

                                try
                                {
                                    CustomerInfo        = CustData.CustomerInfo;
                                    item.PrimaryPhone   = CustomerInfo.PrimaryPhone;
                                    item.AddressTagName = AddressItem.CustAddress.TagName;
                                    item.FirstName      = CustomerInfo.FirstName;
                                }
                                catch { }
                                item.OrderSource = "App";
                                OrderList.Add(item);
                            }
                            catch
                            {
                            }
                        }

                        foreach (var item in items.WooCommerceOrders)
                        {
                            try
                            {
                                item.OrderSource = "Website";
                                OrderList.Add(item);
                            }
                            catch
                            { }
                        }
                    }
                    else
                    {
                        ListFooterText = "No more orders to load";
                    }
                    return(tempItems);
                }
                catch (Exception ex)
                {
                    DependencyService.Get <IToastMessage>().LongTime("Server Error E01: Please try again after sometime.");
                    ListFooterText = "Unable to load the orders";
                    Debug.WriteLine(ex.Message);
                }
                finally
                {
                    IsBusy = false;
                }
            }
            else
            {
                DependencyService.Get <IToastMessage>().LongTime("Check your Internet Connection and try again");
                ListFooterText = "Unable to load the orders";
            }
            return(null);
        }
        public async Task ExecuteLoadCustomerCommand(string storecust_id, string DeliverAddressId, CustomerInvoiceDatum InvoiceDetails)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                IsBusy = true;
                try
                {
                    if (!string.IsNullOrEmpty(storecust_id))
                    {
                        CustomerInfo = new CustomerDetails();
                        AddressInfo  = new AddressDetails();
                        CustomerApiData CustomerItems = await CustomerApiService.Instance.FetchCustomerList(storecust_id);

                        AddressApiData AddressItem = await AddressApiService.Instance.RefreshAddressList(DeliverAddressId);

                        CustomerInfo = CustomerItems.CustomerInfo;
                        AddressInfo  = AddressItem.CustAddress;
                        phoneNumberList.Add(AddressInfo.PrimaryPhone);
                        phoneNumberList.Add(AddressInfo.AlternatePhone);
                        if (String.IsNullOrEmpty(AddressInfo.AlternatePhone))
                        {
                            DisplayAltNumber = false;
                        }
                        else
                        {
                            DisplayAltNumber = true;
                        }
                        if (String.IsNullOrEmpty(AddressInfo.FlatNoDoorNo))
                        {
                            DisplayFlatNumber = false;
                        }
                        else
                        {
                            DisplayFlatNumber = true;
                        }
                        if (String.IsNullOrEmpty(AddressInfo.SocietyBuildingNo))
                        {
                            DisplaySociety = false;
                        }
                        else
                        {
                            DisplaySociety = true;
                        }
                    }
                    else
                    {
                        AddressInfo                   = new AddressDetails();
                        AddressInfo.FirstName         = InvoiceDetails.FirstName;
                        AddressInfo.PrimaryPhone      = InvoiceDetails.PrimaryPhone;
                        AddressInfo.AlternatePhone    = null;
                        DisplayAltNumber              = false;
                        DisplayFlatNumber             = false;
                        AddressInfo.Address1          = InvoiceDetails.Address1;
                        AddressInfo.PostalCodeZipCode = InvoiceDetails.ZipCode;
                        AddressInfo.Address2          = InvoiceDetails.Address2;
                        AddressInfo.TagName           = null;
                        phoneNumberList.Add(AddressInfo.PrimaryPhone);
                        phoneNumberList.Add(AddressInfo.AlternatePhone);
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    IsBusy = false;
                }
            }
            else
            {
                DependencyService.Get <IToastMessage>().LongTime("Check your Internet Connection and try again");
            }
        }