示例#1
0
        public HttpResponseMessage Save(Invoice i)
        {
            try
            {
                var response = _invoiceServices.Save(i);

                var data = new List <IDataResult>
                {
                    response
                };

                var result = new ApiResult(data, Stopwatch, "invoices/save", 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()));
            }
        }