//[ValidateAntiForgeryToken] public JsonResult CustomerPost(string[] values) { Orders newOrder = new Orders(); newOrder.CustomerId = 2; newOrder.Status = "Pending"; bool result = _ordersRepo.Add(newOrder); List <Int32> itemId = new List <Int32>(); List <Int32> itemCount = new List <Int32>(); for (int i = 0; i < values.Length; i++) { var items = values[i].Split('_'); itemId.Add(Int32.Parse(items[0])); itemCount.Add(Int32.Parse(items[1])); } int b = 0; foreach (var item in itemId) { OrderDetails od = new OrderDetails(); od.ItemId = item; od.OrderId = newOrder.Id; od.Quantity = itemCount[b++]; _orderDetailsRepo.Add(od); } return(Json(true)); }
public async Task <ActionResult <Orders> > PostOrder(Orders order) { await _repo.Add(order); return(CreatedAtAction("GetOrdersModel", new { id = order.Id }, order)); }