Exemplo n.º 1
0
        public async Task <int> AddCountryAsync(Country country)
        {
            await _contect.AddAsync(country);

            await _contect.SaveChangesAsync();

            return(country.Id);
        }
Exemplo n.º 2
0
        public async Task <int> AddCityAsync(City city)
        {
            var country = await _worldDbContext.Countries.FindAsync(city.Country.Id);

            city.UpdateCountry(country);
            try
            {
                await _worldDbContext.AddAsync(city);

                await _worldDbContext.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw e;
            }

            return(city.Id);
        }