public ContentResult Add(int flavorId, int quantity) { int orderId; if (Session["OrderId"] == null || !Int32.TryParse(Session["OrderId"].ToString(), out orderId)) { var order = new Order(); rOrder.Create(order); orderId = order.Id; Session["OrderId"] = orderId; } else { Int32.TryParse(Session["OrderId"].ToString(), out orderId); } if (quantity != 0) { CurrentOrder currentOrder = rCurrentOrder.Get(p => p.OrderId == orderId && p.FlavorId == flavorId); if (currentOrder == null) { currentOrder = new CurrentOrder(); currentOrder.FlavorId = flavorId; currentOrder.OrderId = orderId; currentOrder.Quantity = quantity; rCurrentOrder.Create(currentOrder); } else { currentOrder.Quantity += quantity; rCurrentOrder.Update(currentOrder); } } return Content("0", "text/html"); }
public async Task<Order> Put(Order order) { var storedOrder = await _orderRepository.Store(order); return storedOrder; }