示例#1
0
        public IActionResult DeleteCounty(int stateId, int id)
        {
            if (!_myAppRepository.StateExists(stateId))
            {
                return(NotFound());
            }

            var countyEntity = _myAppRepository
                               .GetCountyForState(stateId, id);

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

            _myAppRepository.DeleteCountyForState(countyEntity);
            _myAppRepository.Save();

            _mailService.Send("County Delete",
                              $"{countyEntity.Name} county with Fips {countyEntity.Id} was deleted.");

            return(NoContent());
        }