private void ShowCountries(Сountry x) { tableCntry.Invoke((MethodInvoker) delegate { tableCntry.Rows[x.Number].Cells[2].Value = x.Coins.Count; }); }
public void AddСountry(Сountry сountry) { AddCity(сountry.Capital); AddRegion(сountry.Region); City city = GetCityByName(сountry.Capital.Name); Region region = GetRegionByName(сountry.Region.Name); сountry.Capital = city; сountry.Region = region; Сountry findedСountry = GetСountryByName(сountry.Name); if (findedСountry == null) { _context.Сountries.Add(new Сountry { Name = сountry.Name, СountryCode = сountry.СountryCode, Area = сountry.Area, Population = сountry.Population, Capital = сountry.Capital, Region = сountry.Region }); _context.SaveChanges(); } else { UpdateСountry(сountry, ref findedСountry); } }
public void UpdateСountry(Сountry beforeCountry, ref Сountry afterСountry) { afterСountry.Name = beforeCountry.Name; afterСountry.СountryCode = beforeCountry.СountryCode; afterСountry.Area = beforeCountry.Area; afterСountry.Population = beforeCountry.Population; afterСountry.Capital = beforeCountry.Capital; afterСountry.Region = beforeCountry.Region; _context.SaveChanges(); }
public IActionResult Save(string name, string countryCode, string area, int population, string capitalName, string regionName) { Сountry сountry = new Сountry { Name = name, СountryCode = countryCode, Area = Convert.ToDecimal(area), Population = population, Capital = new City { Name = capitalName }, Region = new Region { Name = regionName } }; _service.AddСountry(сountry); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Details(string name) { string path = $"rest/v2/name/{name}"; var response = await client.GetAsync(path); if (response.StatusCode == HttpStatusCode.NotFound) { return(View("Error", new Error( response.StatusCode, $"Страна «{name}» не найдена."))); } else { var countriesList = await response.Content.ReadAsAsync <IList <Сountry> >(); Сountry country = countriesList.First(); return(View(country)); } }
private void Switcher_Button(object sender, EventArgs e) { switch (((Button)sender).Name) { case "create": Сountries = new List <Сountry>(); for (int i = 0; i < countCountry.Text.ToInt(); i++) { Сountry country = new Сountry(i, "Cntry:" + i); Сountries.Add(country); tableCntry.Rows.Add(i, country.Name, 0, 0, country.DateCreate); } Update(); break; case "start": ModelingLoop(); break; default: break; } }
public Form2(Сountry сountry) { InitializeComponent(); Country = сountry; this.Text = "Отчет: " + Country.Name; }