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); }
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); }
public async Task <CxcCity> GetCityAsync(CxcMunicipality municipality) { return(await _context.CxcCities .Where(c => c.CxcMunicipalities.Any(ci => ci.Id == municipality.Id)) .FirstOrDefaultAsync()); }