private async void GetCountryList(Action action) { CountryProvinces = await DependencyService.Get <IProvinceServices>().GetAsync(); CountryList = CountryProvinces.Select(c => (string)c.CountryName).Distinct().ToList(); action?.Invoke(); }
public async Task <List <string> > GetCountryList() { CountryProvinces = await DependencyService.Get <IProvinceServices>().GetAsync(); CountryList = CountryProvinces.Select(c => (string)c.CountryName).Distinct().ToList(); return(CountryList); }
public List <string> GetStateList(string country) { var provinces = CountryProvinces.FirstOrDefault(p => p.CountryName == country)?.Provinces; StateList = provinces?.Select(p => (string)p.ProvinceName).Distinct().ToList(); return(StateList); }
private void GetStateList() { if (!string.IsNullOrEmpty(CountryName)) { var provinces = CountryProvinces.FirstOrDefault(p => p.CountryName == CountryName)?.Provinces; StateList = provinces?.Select(p => (string)p.ProvinceName).Distinct().ToList(); } }
public static void convertCsvToDictionary(List <dynamic> LocationList, string type) { foreach (var lcsv in LocationList) { var dict = (IDictionary <string, object>)lcsv; string Country = lcsv.countryregion.ToLower(); string Province = lcsv.provincestate.ToLower(); if (!String.IsNullOrEmpty(Country)) { CountryRegions.Add(Country.ToLower()); } if (!String.IsNullOrEmpty(Province)) { ProvinceStates.Add(Province.ToLower()); LocationKey lk = new LocationKey(Country, Province); if (!CountryProvinces.ContainsKey(Country)) { CountryProvinces.Add(Country, new Country()); } //CountryProvinces.Add(lk, new Location(Country, Province, new Coordinates(lcsv.Lat, lcsv.Long))); else { if (!CountryProvinces[Country].Provinces.Contains(Province)) { CountryProvinces[Country].Provinces.Add(Province); } } } DateTime firstDate = DateTime.Parse("1/1/2020"); DateTime endDate = DateTime.Now; int daysToAttempt = (endDate - firstDate).Days + 10; for (int i = 0; i < daysToAttempt; i++) { StatusCount statusCount = new StatusCount(); DateTime dateToAttempt = firstDate.AddDays(i); string targetDay = dateToAttempt.ToString("Mdyy"); if (dict.TryGetValue(targetDay, out var count) && !String.IsNullOrEmpty(count.ToString())) { int intcount = int.Parse(count.ToString()); if (type == "Confirmed") { statusCount.Confirmed = intcount; } else if (type == "Deaths") { statusCount.Deaths = intcount; } else if (type == "Recovered") { statusCount.Recovered = intcount; } Occurences occurences = new Occurences(); occurences.DateOccurrences.Add(dateToAttempt, statusCount); LocationKey location = new LocationKey(Country.ToLower(), Province.ToLower()); if (!LocationOccurrences.ContainsKey(location)) { LocationOccurrences.Add(location, occurences); } if (!LocationOccurrences[location].DateOccurrences.ContainsKey(dateToAttempt)) { LocationOccurrences[location].DateOccurrences[dateToAttempt] = new StatusCount(); } if (type == "Confirmed") { LocationOccurrences[location].DateOccurrences[dateToAttempt].Confirmed = statusCount.Confirmed; } else if (type == "Deaths") { LocationOccurrences[location].DateOccurrences[dateToAttempt].Deaths = statusCount.Deaths; } else if (type == "Recovered") { LocationOccurrences[location].DateOccurrences[dateToAttempt].Recovered = statusCount.Recovered; } } } } }