private void LoadNearbyClinics(ResponseNearbyClinics responseNearbyClinics) { try { Clinics.Clear(); IList <Clinic> nearbyClinics = new List <Clinic>(); foreach (Clinic item in responseNearbyClinics.Clinics) { if (CurrentLocation != null) { item.Distance = ViewModelHelper.Distance(CurrentLocation.Latitude, CurrentLocation.Longitude, double.Parse(item.Latitude.Replace(".", phoneService.CurrentCulture.NumberFormat.CurrencyDecimalSeparator)), double.Parse(item.Longitude.Replace(".", phoneService.CurrentCulture.NumberFormat.CurrencyDecimalSeparator))); } nearbyClinics.Add(item); } IList <Clinic> clinicsOrdered = new List <Clinic>(); if (CurrentLocation != null) { clinicsOrdered = nearbyClinics.OrderBy(x => x.Distance).ToList(); } else { clinicsOrdered = nearbyClinics.OrderBy(x => x.Name).ToList(); } Clinics.Clear(); foreach (var item in clinicsOrdered) { ClinicViewModel clinicViewModel = new ClinicViewModel(); ViewModelHelper.SetClinicToClinicViewModel(clinicViewModel, item, phoneService.CurrentCulture.NumberFormat.CurrencyDecimalSeparator); Clinics.Add(clinicViewModel); } } catch (Exception e) { } }