0
現在,我可以選擇已存在於數據庫中的作業並將其發送到Web API控制器以導出爲PDF。我現在需要創建一個Job,並將它發送到同一時間進行轉換。所以我需要一些幫助來了解如何做到這一點的最佳方式?我需要POST它,然後有一個函數來調用一個操作,獲取在數據庫中創建的最新作業?或者我可以以某種方式將表單轉換爲可以傳遞給Api控制器的對象,然後再進行POST?我會認爲後者會更容易,但我發送對象到api控制器的操作是GET調用?因此,這裏是我如何發送作業已在數據庫如何使用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();
});
}
阿比控制器
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
{
這是我如何創建工作
是的,這正是我所期待的。但是已經創建了id?那是自動創建的服務器端,正確的?我可以使用其他屬性,例如JobNumber嗎? – texas697 2014-09-23 14:01:52