public HttpResponseMessage Invoice([FromUri] int invoiceId) { try { var response = _invoiceServices.Get(invoiceId); var data = new List <IDataResult> { response }; var result = new ApiResult(data, Stopwatch, "invoices/invoice", Token, Nonce, Cookie); return(Request.CreateResponse(HttpStatusCode.OK, result, new JsonMediaTypeFormatter())); } catch (InvalidTokenException tx) { return(Request.CreateResponse(HttpStatusCode.Unauthorized, new { type = "invalid token", message = tx.Message }, new JsonMediaTypeFormatter())); } catch (ValidationException vx) { return(Request.CreateResponse(HttpStatusCode.NotAcceptable, new { type = "validation failure", message = vx.Message }, new JsonMediaTypeFormatter())); } catch (BlueprintAppException appx) { return(Request.CreateResponse(HttpStatusCode.NotAcceptable, new { type = "application exception", message = appx.Message }, new JsonMediaTypeFormatter())); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new { type = "general exception", message = ex.Message }, new JsonMediaTypeFormatter())); } }
public IHttpActionResult GetUsingID(InvoiceViewModel obj) { var getInvoice = service1.Get(obj.Id); return(Ok(getInvoice)); }