Exemple #1
0
        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());
        }
Exemple #2
0
        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());
        }