/// <summary> /// Добавляет указанную информацию о стране в базу данных /// </summary> /// <param name="countryInfo">Информация о стране</param> /// <returns></returns> public async Task SaveCountyInfo(CountryInfoDTO countryInfo) { var capital = await _cityLogic.GetCityByName(countryInfo.CountryCapital); if (capital == null) { capital = new City(countryInfo.CountryCapital); } var region = await _regionLogic.GetRegionByName(countryInfo.Region); if (region == null) { region = new Region(countryInfo.Region); } var country = await _countryLogic.GetCountryByNumericCode(countryInfo.CountryCode); if (country == null) { await _countryLogic.AddNewCountry(new Country() { Name = countryInfo.CountryName, Capital = capital, Region = region, Area = countryInfo.CountryArea, CountryCode = countryInfo.CountryCode, Population = countryInfo.CountryPopulation }); } else { await _countryLogic.UpdateCountry(country, capital, region, countryInfo); } }
public async Task UpdateCountry(Country country, City capital, Region region, CountryInfoDTO countryInfo) { country.Area = countryInfo.CountryArea; country.CountryCode = countryInfo.CountryCode; country.Name = countryInfo.CountryName; country.Population = countryInfo.CountryPopulation; await _countryLogic.UpdateCountry(country); await _cityLogic.UpdateCity(capital); await _regionLogic.UpdateRegion(region); }