public IActionResult UpdateCargo(int cargoId, [FromBody] CargoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_cargoRepository.CargoExists(cargoId)) { return(NotFound()); } var cargo = _mapper.Map <Cargo>(model); _cargoRepository.UpdateCargo(cargo); return(NoContent()); }
public IActionResult UpdateCargo(int cargoId, [FromBody] CargoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_cargoRepository.CargoExists(cargoId)) { return(NotFound($"Cargo {cargoId} não existe!")); } var cargo = new Cargo { CargoId = model.Cargo_Id, CargoDesc = model.Cargo_Desc }; _cargoRepository.UpdateCargo(cargo); return(NoContent()); }