Example #1
0
        private bool AddOrderItem(OrderItem item)
        {
            //store storeid from previous failed order and current qty (overwritten when assigning to previous item)
            int storeID = Convert.ToInt32(TempData["StoreID"]);

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

            TempData["OrderID"] = orderID;
            //validate current item's qty
            if (ModelState.IsValid && item.ValidateQuantity(_locContext.GetQty(item.Pid)))
            {
                //set old failed qty to current entered qty
                //update prod qty, set correspodning order id (always passed)
                _locContext.UpdateInventory(item.Pid, item.Qty);
                item.Oid = orderID;
                _context.AddOrderItem(item);
                logger.LogInformation($"Adding item to {1}", item.Oid);
                return(true);
            }
            ModelState.AddModelError("QuantityError", "Invalid quantity entered, please try again");
            return(false);
        }
Example #2
0
 public void Update(int id, int qty)
 {
     DAL.UpdateInventory(id, qty);
 }