Example #1
0
        public IActionResult Update([FromBody] OccupationForUpdateDto occupationForUpdateDto)
        {
            var result = _occupationService.Update(occupationForUpdateDto);

            if (result.Success)
            {
                return(Ok(result.Object));
            }

            if (!string.IsNullOrEmpty(result.Message))
            {
                return(BadRequest(new { error = result.Message }));
            }

            return(StatusCode(500));
        }
Example #2
0
        public ResponseObject <OccupationForGetDto> Update(OccupationForUpdateDto occupationForUpdateDto)
        {
            var occupationForCheckId = _occupationRepository.GetById(occupationForUpdateDto.Id);

            if (occupationForCheckId == null)
            {
                return(new ResponseObject <OccupationForGetDto>(false, "Não existe um cargo com o ID informado"));
            }

            var occupationForUpdate = _mapper.Map <Occupation>(occupationForUpdateDto);

            _occupationRepository.Update(occupationForUpdate);
            var commit = _unityOfWork.Commit();

            return(commit
                ? new ResponseObject <OccupationForGetDto>(true, obj: _mapper.Map <OccupationForGetDto>(occupationForUpdate))
                : new ResponseObject <OccupationForGetDto>(false));
        }