public IActionResult FindByDocumentNumber([FromQuery] string DocumentNumber) { bool uowStatus = false; try { Provider provider = new Provider(); Notification notification = provider.ValidateFindByDocumentNumber(DocumentNumber); if (notification.HasErrors()) { throw new ArgumentException(notification.ErrorMessage()); } Specification <Provider> specification = GetFindByDocumentNumber(DocumentNumber); uowStatus = _unitOfWork.BeginTransaction(); provider = _providerRepository.FindByAnySpecificField(specification); _unitOfWork.Commit(uowStatus); ProviderDto providerDto = _providerAssembler.FromProviderToProviderDto(provider); return(StatusCode(StatusCodes.Status200OK, providerDto)); } catch (ArgumentException ex) { return(BadRequest(_responseHandler.getAppCustomErrorResponse(ex.Message))); } catch (Exception ex) { _unitOfWork.Rollback(uowStatus); Console.WriteLine(ex.StackTrace); return(StatusCode(StatusCodes.Status500InternalServerError, this._responseHandler.getAppExceptionResponse())); } }