コード例 #1
0
        private bool AddOrderItem(OrderLine item)
        {
            int StoreId = Convert.ToInt32(TempData["StoreId"]);

            TempData["StoreId"] = StoreId;
            int orderID = Convert.ToInt32(TempData["OrderID"]);

            TempData["OrderId"] = orderID;


            if (ModelState.IsValid && item.ValidateQuantity(_storeContext.GetQuantity(item.ProductId)))
            {
                _storeContext.UpdateInventory(item.ProductId, item.Quantity);
                item.SaleId      = orderID;
                item.InventoryId = item.ProductId;
                Debug.WriteLine(orderID);
                _context.AddOrderLine(item);
                return(true);
            }
            ModelState.AddModelError("QuantityError", "Invalid quantity");
            return(false);
        }