Esempio n. 1
0
        public HttpResponseMessage Post(Order docvenda)
        {
            RespostaErro erro = new RespostaErro();

            erro = Comercial.InsertOrder(docvenda);

            if (erro.Erro == 0)
            {
                var response = Request.CreateResponse(
                    HttpStatusCode.Created, docvenda);
                string uri = Url.Link("ActionApi", new { NumDoc = docvenda.CodArtigo });
                response.Headers.Location = new Uri(uri);
                return(response);
            }
            else if (erro.Erro == 1)
            {
                var response = Request.CreateResponse(
                    HttpStatusCode.Created, erro.Descricao);
                return(response);
            }

            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }