From 9b6b690689a6bd5471a8a7f9d40df44a7ec8a6a8 Mon Sep 17 00:00:00 2001 From: Swagata Prateek Date: Sun, 1 May 2016 12:02:53 +0600 Subject: [PATCH] Added changes on docs and took off some exception catches so errors are properly served --- TaskCat/TaskCat/Controller/JobController.cs | 48 ++++++--------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/TaskCat/TaskCat/Controller/JobController.cs b/TaskCat/TaskCat/Controller/JobController.cs index 8605b9a..b7a3825 100644 --- a/TaskCat/TaskCat/Controller/JobController.cs +++ b/TaskCat/TaskCat/Controller/JobController.cs @@ -111,16 +111,9 @@ public async Task List(string type = "", int pageSize = AppCo pageSize = pageSize > AppConstants.MaxPageSize ? AppConstants.MaxPageSize : pageSize; - try - { - if (envelope) - return Json(await repository.GetJobsEnveloped(type, page, pageSize, this.Request)); - return Json(await repository.GetJobs(type, page, pageSize)); - } - catch (Exception ex) - { - return InternalServerError(ex); - } + if (envelope) + return Json(await repository.GetJobsEnveloped(type, page, pageSize, this.Request)); + return Json(await repository.GetJobs(type, page, pageSize)); } /// @@ -231,7 +224,7 @@ public async Task GenerateInvoiceForAJob(string jobhrid) { Content = new ByteArrayContent(invoiceStream.GetBuffer()) }; - reponseMessage.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") + reponseMessage.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = string.Concat(invoice.InvoiceId, ".pdf") }; @@ -253,15 +246,8 @@ public async Task GenerateInvoiceForAJob(string jobhrid) [HttpPost] public async Task Post(JobModel model) { - try - { - Job job = await repository.PostJob(model); - return Json(job); - } - catch (Exception) - { - return InternalServerError(); - } + Job job = await repository.PostJob(model); + return Json(job); } /// @@ -277,6 +263,7 @@ public async Task Post(JobModel model) /// Returns a replace result that replaces the JobServedBy field /// /// + [ResponseType(typeof(ReplaceOneResult))] [Authorize(Roles = "Administrator, BackOfficeAdmin")] [Route("api/Job/claim/{jobId}")] [HttpPost] @@ -298,25 +285,18 @@ public async Task Claim(string jobId) /// /// /// - /// + /// + /// Returns a ReplaceOneResult based on the update + /// + /// + [ResponseType(typeof(ReplaceOneResult))] [Authorize(Roles = "Asset, Administrator, Enterprise, BackOfficeAdmin")] [Route("api/Job/{jobId}/{taskId}")] [HttpPatch] public async Task Update([FromUri]string jobId, [FromUri] string taskId, [FromBody] JsonPatchDocument taskPatch) { - try - { - ReplaceOneResult result = await repository.UpdateJobWithPatch(jobId, taskId, taskPatch); - return Json(result); - } - catch (InvalidOperationException ex) - { - return Content(System.Net.HttpStatusCode.Forbidden, ex); - } - catch (ArgumentException ex) - { - return BadRequest(ex.Message); - } + ReplaceOneResult result = await repository.UpdateJobWithPatch(jobId, taskId, taskPatch); + return Json(result); } }