private async void LoadListData(ApplicationActivity pageType)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                bool                isCallFirstTime = false;
                ReqProductModel     productType     = new ReqProductModel();
                ApproveServiceModel approveModel    = new ApproveServiceModel();
                HttpClientHelper    apicall         = new HttpClientHelper(ApiUrls.Url_GetApprovedInProgressServiceList, Settings.AccessTokenSettings);
                productType.productType = pageType;

                var regjson  = JsonConvert.SerializeObject(productType);
                var response = await apicall.Post <List <ApproveServiceModel> >(regjson);

                switch (pageType)
                {
                case ApplicationActivity.CheckApprovedServiceStatusListPage:
                    ApproveBackgroundColor    = Color.FromHex("#981C1C");
                    InProgressBackgroundColor = Color.FromHex("#000000");
                    if (response != null)
                    {
                        if (response.Count > 0)
                        {
                            IsStatusVisible      = false;
                            ServiceComplaintList = new ObservableCollection <ApproveServiceModel>(response);
                        }
                        else
                        {
                            IsStatusVisible = true;
                            UserDialogs.Instance.HideLoading();
                        }
                    }
                    break;

                case ApplicationActivity.CheckInprogressServiceStatusListPage:
                    ApproveBackgroundColor    = Color.FromHex("#000000");
                    InProgressBackgroundColor = Color.FromHex("#981C1C");
                    if (response != null)
                    {
                        if (response.Count > 0)
                        {
                            IsStatusVisible      = false;
                            ServiceComplaintList = new ObservableCollection <ApproveServiceModel>(response);
                        }
                        else
                        {
                            IsStatusVisible = true;
                            UserDialogs.Instance.HideLoading();
                        }
                    }
                    break;

                default:
                    break;
                }
            }
            else
            {
                UserDialogs.Instance.HideLoading();
                await Application.Current.MainPage.DisplayAlert("Network", AppConstant.NETWORK_FAILURE, "OK");

                return;
            }
            UserDialogs.Instance.HideLoading();
        }
Example #2
0
        private async void LoadProductListData(ApplicationActivity pageType)
        {
            try
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    bool             isCallFirstTime = false;
                    ReqProductModel  productType     = new ReqProductModel();
                    HttpClientHelper apicall         = new HttpClientHelper(ApiUrls.Url_GetProductListData, Settings.AccessTokenSettings);
                    productType.productType = pageType;

                    var regjson  = JsonConvert.SerializeObject(productType);
                    var response = await apicall.Post <ProductListResponseModel>(regjson);

                    if (response != null)
                    {
                        switch (pageType)
                        {
                        case ApplicationActivity.Electrical:
                            if (response.electrical != null)
                            {
                                Cache.globalCatagory = "Electrical";
                                PageSubHeaderText    = "Electrical";
                                foreach (var item in response.electrical)
                                {
                                    string filepath = AppSetting.Root_Url + item.serviceImage;
                                    //byte[] imageByte = null;
                                    //imageByte = Convert.FromBase64String(item.serviceImage);
                                    ProductModel productModel = new ProductModel();
                                    productModel.ProductName  = item.serviceName;
                                    productModel.ProductImage = filepath;     //ImageSource.FromUri(new Uri(filepath));  //ImageSource.FromStream(() => new MemoryStream(imageByte));
                                    ProductList.Add(productModel);
                                }
                            }
                            break;

                        case ApplicationActivity.Electronic:
                            if (response.electronic != null)
                            {
                                Cache.globalCatagory = "Electronics";
                                PageSubHeaderText    = "Electronics";
                                foreach (var item in response.electronic)
                                {
                                    string filepath = AppSetting.Root_Url + item.serviceImage;
                                    //byte[] imageByte = null;
                                    //imageByte = Convert.FromBase64String(item.serviceImage);
                                    ProductModel productModel = new ProductModel();
                                    productModel.ProductName  = item.serviceName;
                                    productModel.ProductImage = filepath;     //ImageSource.FromUri(new Uri(filepath));  //ImageSource.FromStream(() => new MemoryStream(imageByte));
                                    ProductList.Add(productModel);
                                }
                            }
                            break;

                        case ApplicationActivity.IT:
                            if (response.it != null)
                            {
                                Cache.globalCatagory = "IT";
                                PageSubHeaderText    = "IT";
                                foreach (var item in response.it)
                                {
                                    string filepath = AppSetting.Root_Url + item.serviceImage;
                                    //byte[] imageByte = null;
                                    //imageByte = Convert.FromBase64String(item.serviceImage);
                                    ProductModel productModel = new ProductModel();
                                    productModel.ProductName  = item.serviceName;
                                    productModel.ProductImage = filepath;     //ImageSource.FromUri(new Uri(filepath));  //ImageSource.FromStream(() => new MemoryStream(imageByte));
                                    ProductList.Add(productModel);
                                }
                            }
                            break;

                        case ApplicationActivity.DailyNeeds:
                            if (response.dailyNeeds != null)
                            {
                                Cache.globalCatagory = "Daily Services";
                                PageSubHeaderText    = "Daily Services";
                                foreach (var item in response.dailyNeeds)
                                {
                                    string filepath = AppSetting.Root_Url + item.serviceImage;
                                    //byte[] imageByte = null;
                                    //imageByte = Convert.FromBase64String(item.serviceImage);
                                    ProductModel productModel = new ProductModel();
                                    productModel.ProductName  = item.serviceName;
                                    productModel.ProductImage = filepath;     //ImageSource.FromUri(new Uri(filepath));  //ImageSource.FromStream(() => new MemoryStream(imageByte));
                                    ProductList.Add(productModel);
                                }
                            }
                            break;

                        default:
                            break;
                        }
                    }

                    ProductData = new ReadOnlyObservableCollection <ProductModel>(ProductList);
                    if (Cache.globalCatagory == "Electronics")
                    {
                        Device.StartTimer(TimeSpan.FromSeconds(10), () =>
                        {
                            if (isCallFirstTime == false)
                            {
                                isCallFirstTime = true;
                                UserDialogs.Instance.HideLoading();
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        });
                    }
                    else
                    {
                        Device.StartTimer(TimeSpan.FromSeconds(4), () =>
                        {
                            if (isCallFirstTime == false)
                            {
                                isCallFirstTime = true;
                                UserDialogs.Instance.HideLoading();
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        });
                    }
                }
                else
                {
                    UserDialogs.Instance.HideLoading();
                    await Application.Current.MainPage.DisplayAlert("Network", AppConstant.NETWORK_FAILURE, "OK");

                    return;
                }
            }
            catch (Exception)
            {
                UserDialogs.Instance.HideLoading();
            }
        }