Beispiel #1
0
        // Apagar Cidade
        public async Task <IActionResult> DeleteCity(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var city = await _countryRepository.GetCityAsync(id.Value);

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

            try
            {
                var countryId = await _countryRepository.DeleteCityAsync(city);

                return(this.RedirectToAction($"Details/{countryId}"));
            }
            catch (Exception)
            {
                ViewBag.Message = "City can't be deleted, is linked to a field in use";
                return(View());
            }
        }
        public async Task <IActionResult> DeleteCity(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var city = await _countryRepository.GetCityAsync(id.Value);

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

            var countryId = await _countryRepository.DeleteCityAsync(city);

            return(this.RedirectToAction($"Details/{countryId}"));
        }