public async Task <ActionResult <City> > AddCityAsync(City city) { var addReturn = await _cityRepository.Add(city); if (addReturn != null) { return(CreatedAtAction("GetCity", new { id = city.Id }, city)); } return(BadRequest()); }
public async Task <ActionResult <User> > AddUserAsync(User user) { try { var addReturn = await _userRepository.Add(user); if (addReturn != 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 })); } }