Skip to content

Commit

Permalink
Added changes on docs and took off some exception catches so errors a…
Browse files Browse the repository at this point in the history
…re properly served
  • Loading branch information
thehoneymad committed May 1, 2016
1 parent 5827f8b commit 9b6b690
Showing 1 changed file with 14 additions and 34 deletions.
48 changes: 14 additions & 34 deletions TaskCat/TaskCat/Controller/JobController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,9 @@ public async Task<IHttpActionResult> 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));
}

/// <summary>
Expand Down Expand Up @@ -231,7 +224,7 @@ public async Task<IHttpActionResult> 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")
};
Expand All @@ -253,15 +246,8 @@ public async Task<IHttpActionResult> GenerateInvoiceForAJob(string jobhrid)
[HttpPost]
public async Task<IHttpActionResult> 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);
}

/// <summary>
Expand All @@ -277,6 +263,7 @@ public async Task<IHttpActionResult> Post(JobModel model)
/// Returns a replace result that replaces the JobServedBy field
/// </returns>
///
[ResponseType(typeof(ReplaceOneResult))]
[Authorize(Roles = "Administrator, BackOfficeAdmin")]
[Route("api/Job/claim/{jobId}")]
[HttpPost]
Expand All @@ -298,25 +285,18 @@ public async Task<IHttpActionResult> Claim(string jobId)
/// </param>
/// <param name="taskId"></param>
/// <param name="taskPatch"></param>
/// <returns></returns>
/// <returns>
/// Returns a ReplaceOneResult based on the update
/// </returns>
///
[ResponseType(typeof(ReplaceOneResult))]
[Authorize(Roles = "Asset, Administrator, Enterprise, BackOfficeAdmin")]
[Route("api/Job/{jobId}/{taskId}")]
[HttpPatch]
public async Task<IHttpActionResult> Update([FromUri]string jobId, [FromUri] string taskId, [FromBody] JsonPatchDocument<JobTask> 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);
}

}
Expand Down

0 comments on commit 9b6b690

Please sign in to comment.