P1_TrevorGraham/MvcStoreApplication/Repository/Repository.cs
/// <summary>
/// adds order to order line, decrements inventories for order line, and then saves to the db; returns true if successful
/// </summary>
/// <param name="cart"></param>
/// <param name="orderLine"></param>
/// <returns></returns>
adds order to order line, decrements inventories for order line, and then saves to the db; returns true if successful
adds order to order line decrements inventories for order line and then saves to the db ; returns true if successful
public bool AddItemToCart(Order cart, OrderLine orderLine)
        {
            if (cart.OrderIsComplete)
            {
                return false;
            }
            orderLine.Inventory.Quantity -= orderLine.Quantity;
            orderLine.Order = cart;
            _dbContext.OrderLines.Add(orderLine);
            _dbContext.SaveChanges();
            return true;
        }
public bool AddItemToCart ( Order cart , OrderLine orderLine ) { if ( cart . OrderIsComplete ) { return false ; } orderLine . Inventory . Quantity -= orderLine . Quantity ; orderLine . Order = cart ; _dbContext . OrderLines . Add ( orderLine ) ; _dbContext . SaveChanges ( ) ; return true ; }
adds order to order line, decrements inventories for order line, and then saves to the db; returns true if successful
adds order to order line decrements inventories for order line and then saves to the db ; returns true if successful
None
cart
Order
None
orderLine
OrderLine
None