public async Task <IActionResult> Post(RestRoomPerson restRoomPerson) { try { _repository.Add(restRoomPerson); if (await this._repository.SaveChangesAsync()) { return(Ok(restRoomPerson)); } } catch (Exception ex) { return(BadRequest($"When posting the restroom_person, an error ocurred: {ex.Message}")); } return(BadRequest()); }
public async Task <IActionResult> Put(int restRoomPersonId, RestRoomPerson restRoomPerson) { try { var registeredRestRoomPerson = await _restRoomPerson.GetByIdAsync(restRoomPersonId); if (registeredRestRoomPerson == null) { return(NotFound()); } _repository.Update(restRoomPerson); if (await _repository.SaveChangesAsync()) { return(Ok(restRoomPerson)); } } catch (Exception ex) { return(BadRequest($"When updating the restroom_person, an error ocurred: {ex.Message}")); } return(BadRequest()); }