public void LoadCurrents(AbsolutePlace place) { var countries = namazApi.GetCountries(); countries.ForEach(c => Countries.Add(c)); if (!string.IsNullOrWhiteSpace(place.Country?.UlkeID) && Countries.Any()) { var selectedCnt = Countries.FirstOrDefault(c => c.UlkeID == place.Country?.UlkeID); SelectedCountry = selectedCnt; var cities = namazApi.GetCities(selectedCnt.UlkeID); cities.ForEach(c => Cities.Add(c)); if (!string.IsNullOrWhiteSpace(place.City?.SehirID)) { var selectedCity = Cities.FirstOrDefault(c => c.SehirID == place.City?.SehirID); SelectedCity = selectedCity; var towns = namazApi.GetTowns(selectedCity.SehirID); towns.ForEach(i => Towns.Add(i)); if (!string.IsNullOrWhiteSpace(place.Town?.IlceID)) { var selectedTown = Towns.FirstOrDefault(t => t.IlceID == place.Town?.IlceID); SelectedTown = SelectedTown; } else { var cityCenter = towns.FirstOrDefault(t => t.IlceAdi == selectedCity.SehirAdi); SelectedTown = cityCenter; } } } }
protected override void OnAppearing() { base.OnAppearing(); if (Countries.Any()) { return; } LoadCountries(); }
private void DivideCountries() { do { SetNextPlayer(true); var countriesWithoutOwner = Countries.Where(country => country.Owner == null).ToList(); countriesWithoutOwner[rnd.Next(0, countriesWithoutOwner.Count - 1)].Owner = CurrentPlayer; playersWithTroopsInStartupPhase[CurrentPlayer]--; } while (Countries.Any(country => country.Owner == null)); }
public async Task <IActionResult> IsValidCountry(string Country) { if (Countries.Any(Country.Contains)) { return(Json(true)); } else { return(Json($"Country {Country} does not exists")); } }
///<summary> /// Adds the country. /// </summary> /// <param name="contact">The contact.</param> public void AddCountry(Country country) { if (Countries == null) { Countries = new List <Country>(); } // If the address is not already in the list if (!Countries.Any(x => x.PrimaryKey == country.PrimaryKey)) { Countries.Add(country); //country.AddCurrency(this); } }
public string GetCountryValue(string countryCode) { if (!Countries.Any()) { return(null); } if (string.IsNullOrEmpty(countryCode)) { return(null); } var country = Countries.FirstOrDefault(c => c.Code.Equals(countryCode, StringComparison.OrdinalIgnoreCase)); return(country != null ? country.Value : null); }
public string GetCountryCode(string countryValue) { if (!Countries.Any()) { return(null); } if (string.IsNullOrEmpty(countryValue)) { return(null); } var country = Countries.FirstOrDefault(c => c.Translations.Any(t => t.Value != null && t.Value.Contains(countryValue))); return(country != null ? country.Code : null); }
public override void EnsureSeeded() { /* add seeding data here */ if (!Countries.Any()) { var data = SeedDataReader.ReadCsv <Country>(typeof(ProjectContext).Assembly); AddRange(data); } if (!ProjectManagers.Any()) { var data = SeedDataReader.ReadCsv <ProjectManager>(typeof(ProjectContext).Assembly); AddRange(data); } SaveChanges(); }
private async Task <bool> CheckCountry(IServiceProvider services) { if (Countries != null && Countries.Any()) { var locationInfo = await GetGeoLocation(services); if (locationInfo == null) { return(Countries.Contains("unknown")); } else { return(Countries.Contains(locationInfo.CountryCode)); } } return(true); }
private async void LoadCountries() { if (Countries.Any()) { Indicator.IsVisible = false; } LoadButton.Text = "Atualizando"; IsBusy = true; List.IsVisible = true; Response.Text = string.Empty; try { var result = await DataService.GetCountries(); Countries.Clear(); foreach (var item in result) { Countries.Add(new CountryViewModel(item) { FlagSource = ImageSource.FromUri(DataService.GetFlagSource(item.Alpha2Code)), BrowseCommand = new Command <CountryViewModel>(BrowseCountry) }); } Response.Text = string.Empty; StatusPanel.IsVisible = false; } catch (Exception ex) { Response.Text = ex.Message; StatusPanel.IsVisible = true; List.IsVisible = false; } finally { IsBusy = false; LoadButton.Text = "Atualizar"; } }
public ActionResult EditCountry(CountryModel model) { if (ModelState.IsValid) { if (model.Id > 0) { countryService.UpdateCountry(model); } else { if (!Countries.Any(m => m.CountryName.ToLower().Equals(model.CountryName.ToLower()))) { countryService.InsertCountry(model); } } return(Json(new { Message = @"Thành công", Success = true }, JsonRequestBehavior.AllowGet)); } return(PartialView("_CountryFormEdit", model)); }
public Form1() { InitializeComponent(); PlayerInventory.Clear(); foreach (string s in ProductName) { PlayerInventory.Add(s, 5); } if (!Countries.Any()) { Country Gaia = new Country(); Gaia.Name = "None"; Countries.Add(Gaia); Gaia.Color = Color.Gray; } if (!Provinces.Any()) { foreach (Label ctrl in Map.Controls) { MakeHex(ctrl); Province prv = new Province(ctrl); Provinces.Add(prv); ctrl.Click += new EventHandler(ProvinceClick); prv.Terrain = "water"; prv.Development = 1; prv.Fortifications = 0; ctrl.Text = "#"; GetByObject(ctrl).Owner = GetByName("None"); GetByName("None").Land.Add(prv); prv.Occ = null; } } TerrainBox.TextChanged += new EventHandler(TerrainChange); IEnumerable <Province> query = Provinces.OrderBy(n => n.ctrl.Name); Provinces = query.ToList(); PlayerCurrent = Provinces[150]; Provinces[150].Terrain = "grassland"; Tabs.SelectedIndexChanged += Tabs_TabIndexChanged; foreach (Province pr in GetSurrounding(Provinces[150])) { pr.Terrain = "grassland"; } Prices.Add("wood", 50); Prices.Add("bricks", 75); Prices.Add("wheat", 40); Prices.Add("metals", 200); Prices.Add("tools", 350); Prices.Add("weapons", 500); Prices.Add("wool", 100); Prices.Add("cloth", 400); Prices.Add("furs", 300); Prices.Add("ale", 175); Prices.Add("wine", 300); Prices.Add("spices", 700); Prices.Add("salt", 150); Prices.Add("meat", 150); Prices.Add("hemps", 100); }
private bool IsCountryPassed(CoinModel coin) { return(Countries.Any(x => x.IsPassed(coin.Country))); }