public async Task <ActionResult <User> > DeleteUserAsync(int id) { try { var user = await _userRepository.Get(id); if (user == null) { return(NotFound()); } var deleteReturn = _userRepository.Delete(user); if (deleteReturn != null) { return(CreatedAtAction("GetUser", new { id = user.Id }, user)); } return(BadRequest()); } catch (Exception e) { return(BadRequest(new { message = "Error to find user", exception = e.Message, innerExeption = e.InnerException?.Message })); } }
public async Task <ActionResult <City> > DeleteCityAsync(int id) { var city = await _cityRepository.Get(id); if (city == null) { return(NotFound()); } var deleteReturn = _cityRepository.Delete(city); if (deleteReturn != null) { return(CreatedAtAction("GetCity", new { id = city.Id }, city)); } return(BadRequest()); }