2014-09-23 2 views
0

지금 데이터베이스에 이미있는 작업을 선택하여 웹 API 컨트롤러로 보내어 PDF로 내보낼 수 있습니다. 나는 지금 일자리를 만들고 동시에 그것을 개조하기 위해 그것을 보낼 필요가있다. 그래서이 일을하는 가장 좋은 방법은 어떤 도움이 필요합니까? 그것을 POST 할 필요가 다음 DB에서 만든 최신 작업 얻는 작업 호출 할 함수가? 아니면 POST를하기 전에 양식을 어떻게 든 Api 컨트롤러로 전달할 수있는 객체로 바꿀 수 있습니까? 나는 후자가 더 쉬울 것이라고 생각하지만 API 컨트롤러에 객체를 보내는 Action은 GET 호출이다. 제가 DB에서 이미 작업을 전송하고 어떻게 그래서 여기입니다약속으로 GET으로 POST하는 방법

<div class="inline-fields"> 
<label>JobId:</label> 
<input ng-model="currentItem.JobId" type="text"> 
<label>JobName:</label> 
<input ng-model="currentItem.JobName" type="text"> 
</div> 

<input ng-click="EmailPdf(currentItem)" type="button" value="Email"/> 

컨트롤러

$scope.EmailPdf = function() { 
    var id = $scope.currentItem.JobId 
    $http.get('/api/Pdf/' + id).success(function() { 
     $scope.PrintPreviewModal(); 
    }); 
} 

의 API 컨트롤러

public string Get(int? id) 
    { 
     if (!id.HasValue) 
     { 
      return string.Empty; 
     } 
    JobDataAdapter adapter = new JobDataAdapter(); 
     Job job = new Job(); 
     job = adapter.GetJob(id); 
     if (job == null) 
     { 
      return string.Empty; 
     } 
     try 
     { 

이 내가 작업을 생성하는 방법이다

답변

0

내가 ' 다시 시도하면 PostNewJob 호출 성공으로 pdf 함수를 호출 할 수 있습니다. 다음과 같음 :

$http.post('/api/apiJob/PostNewJob', data).success(function (data, status, headers) { 
    console.log(data); 
    // use the new object to call the Pdf api 
    $http.get('/api/Pdf/' + data.id).success(function() { 
     $scope.PrintPreviewModal(); 
     window.top.location.reload(); 
    }); 
}); 
+0

네, 그게 내가 찾고있는 것입니다. 아직 이드가 만들어져 있니? 그것은 자동으로 서버 측에서 생성 되었습니까? JobNumber와 같은 다른 속성을 사용할 수 있습니까? – texas697