Beispiel #1
0
        private async void GetCountryDetailApi()
        {
            if ((Connectivity.ConnectionProfiles.Contains(ConnectionProfile.WiFi) && Connectivity.NetworkAccess.Equals(NetworkAccess.Internet)) || (Connectivity.ConnectionProfiles.Contains(ConnectionProfile.Cellular) && Connectivity.NetworkAccess.Equals(NetworkAccess.Internet)))
            {
                CountryDetailModel response;
                try
                {
                    response = await webApiRestClient.GetAsync <CountryDetailModel>(ApiHelpers.GetCountries);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("CountryDetailApi_Exception:- " + ex.Message);
                    response = null;
                }
                if (response != null)
                {
                    if (response.status)
                    {
                        countryDetailData = response.Data;
                        foreach (var data in countryDetailData)
                        {
                            CountryPickerList.Add(data);
                            CountryCodeList.Add(data);
                        }
                    }
                    else
                    {
                        await MaterialDialog.Instance.SnackbarAsync(message : response.message,
                                                                    msDuration : 1000);

                        countryDetailData = null;
                    }
                }
                else
                {
                    await MaterialDialog.Instance.SnackbarAsync(message : AppResource.ServerError,
                                                                msDuration : 1000);

                    countryDetailData = null;
                }
            }
            else
            {
                await MaterialDialog.Instance.SnackbarAsync(message : AppResource.NoInternetError,
                                                            msDuration : 1000);
            }
        }
        private async void GetCountryDetailApi()
        {
            if (Connectivity.NetworkAccess.Equals(NetworkAccess.Internet) || Connectivity.ConnectionProfiles.Contains(ConnectionProfile.WiFi))
            {
                CountryDetailModel response;
                try
                {
                    response = await webApiRestClient.GetAsync <CountryDetailModel>(ApiHelpers.GetCountries);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("CountryDetailApi_Exception:- " + ex.Message);
                    response = null;
                }
                if (response != null)
                {
                    if (response.status)
                    {
                        countryDetailData = response.Data;
                        foreach (var data in countryDetailData)
                        {
                            CountryPickerList.Add(data);
                            CountryCodeList.Add(data);
                        }

                        var item = CountryPickerList.Where(x => x.CountryId == profileData.CountryId).FirstOrDefault();
                        CountrySelectedIndexChanged = CountryPickerList.IndexOf(item);

                        var CountryCodeitem = CountryCodeList.Where(x => x.CountryCode == profileData.CountryCode).FirstOrDefault();
                        SelectedIndexChanged = CountryCodeList.IndexOf(item);

                        //if (countryDetailData != null)
                        //{
                        //    foreach (var data in countryDetailData)
                        //    {
                        //        if (profileData.CountryId == data.CountryId)
                        //        {
                        //            CountrySelectedIndexChanged = data.CountryId - 1;
                        //        }
                        //    }
                        //}
                    }
                    else
                    {
                        await MaterialDialog.Instance.SnackbarAsync(message : response.message,
                                                                    msDuration : MaterialSnackbar.DurationShort);

                        countryDetailData = null;
                    }
                }
                else
                {
                    await MaterialDialog.Instance.SnackbarAsync(message : AppResource.ServerError,
                                                                msDuration : MaterialSnackbar.DurationShort);

                    countryDetailData = null;
                }
            }
            else
            {
                await MaterialDialog.Instance.SnackbarAsync(message : AppResource.NoInternetError,
                                                            msDuration : MaterialSnackbar.DurationShort);
            }
        }