public HttpResponseMessage PostOrderLineItems(object order) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} //var lineItemModel = lineItem.ToModel(); var lineItems = new LineItemHelper(); var items = lineItems.Parse(order); var postCount = 0; foreach (LineItem item in items) { var repo = new LineItemsRepository(); repo.Post(item); var adjustInventory = new ProductsRepository(); adjustInventory.DecrementProductCount(item.VariantId, item.Quantity); postCount += 1; } return(items.Count == postCount?Request.CreateResponse(HttpStatusCode.Created) : Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Could not process your order, try again later...")); }