// POST: api/OrderJson?x=value //[ResponseType(typeof(OrderSet))] public IHttpActionResult PostSupplierResponse([FromBody] JObject Response, string x) { OrderTreatment _treatment = new OrderTreatment(); OrderSet _orderSet = new OrderSet(); List <Product> _products = new List <Product>(); string _Message = ""; _orderSet = Response["Order"].ToObject <OrderSet>(); _products = Response["Products"].ToObject <List <Product> >(); _Message = Response["Message"].ToObject <string>(); if (_treatment.OrderStatus(_products, ref _Message)) { _treatment.Invoice(_orderSet); } return(CreatedAtRoute("DefaultApi", new { id = _orderSet.IdOrder }, Response)); }
// POST: api/OrderJson public IHttpActionResult PostOrder([FromBody] JObject Response) { OrderTreatment _treatment = new OrderTreatment(); OrderSet orderSet = new OrderSet(); orderSet = Response.ToObject <OrderSet>(); List <Product> Products = new List <Product>(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (_treatment.Validation(ref orderSet, ref Products)) { orderSet.Note = "Commande enregistrée"; //_treatment.Insert(orderSet); //Products.Add(db.Product.FirstOrDefault()); } else { orderSet.Note = "Certains élements de la commande ne sont pas identifiables"; } if (Products.Count() == 0 || Products == null) { _treatment.Invoice(orderSet); return(Ok(Products)); } else { orderSet.Note = "Ces produits n'ont pas été trouvés"; return(CreatedAtRoute("DefaultApi", new { id = orderSet.IdOrder }, order)); } }