Exemple #1
0
        public async Task <int> DeleteMunicipalityAsync(CxcMunicipality municipality)
        {
            var city = await _context.CxcCities.Where(c => c.CxcMunicipalities.Any(ci => ci.Id == municipality.Id)).FirstOrDefaultAsync();

            if (city == null)
            {
                return(0);
            }

            _context.CxcMunicipalities.Remove(municipality);
            await _context.SaveChangesAsync();

            return(city.Id);
        }
Exemple #2
0
        public async Task <int> UpdateMunicipalityAsync(CxcMunicipality city)
        {
            var country = await _context.CxcCities.Where(c => c.CxcMunicipalities.Any(ci => ci.Id == city.Id)).FirstOrDefaultAsync();

            if (country == null)
            {
                return(0);
            }

            _context.CxcMunicipalities.Update(city);
            await _context.SaveChangesAsync();

            return(country.Id);
        }
Exemple #3
0
 public async Task <CxcCity> GetCityAsync(CxcMunicipality municipality)
 {
     return(await _context.CxcCities
            .Where(c => c.CxcMunicipalities.Any(ci => ci.Id == municipality.Id))
            .FirstOrDefaultAsync());
 }