Exemplo n.º 1
0
        public HttpResponseMessage PostSale(Sale sale)
        {
            var createdSale = SaleServices.CreateSale(sale);

            var response = Request.CreateResponse(HttpStatusCode.Created, sale, Configuration.Formatters.JsonFormatter);

            response.Headers.Add("API-Version", apiVersion);
            response.Headers.Add("HTTP-Method", "POST");

            if (Request.RequestUri.AbsoluteUri.EndsWith("/"))
            {
                response.Headers.Add("New-Sale-URL", Request.RequestUri.AbsoluteUri + createdSale.ID);
            }
            else
            {
                response.Headers.Add("New-Sale-URL", Request.RequestUri.AbsoluteUri + "/" + createdSale.ID);
            }
            return(response);
        }