P1_TrevorGraham/MvcStoreApplication/Repository/Repository.cs
/// <summary>
/// removes an order line from the db; fails if line is not part of an order or if the order is already complete
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
removes an order line from the db; fails if line is not part of an order or if the order is already complete
removes an order line from the db ; fails if line is not part of an order or if the order is already complete
public bool RemoveOrderLineFromOrder(OrderLine line)
        {
            if(line == null)
            {
                return false;
            }
            if (line.Order == null)
                return false;
            if (line.Order.OrderIsComplete)
            {
                return false;
            }
            if (_dbContext.OrderLines.Contains(line))
            {
                line.Inventory.Quantity += line.Quantity;
                _dbContext.OrderLines.Remove(line);
                _dbContext.SaveChanges();
                return true;
            }
            return false;
        }
public bool RemoveOrderLineFromOrder ( OrderLine line ) { if ( line == null ) { return false ; } if ( line . Order == null ) return false ; if ( line . Order . OrderIsComplete ) { return false ; } if ( _dbContext . OrderLines . Contains ( line ) ) { line . Inventory . Quantity += line . Quantity ; _dbContext . OrderLines . Remove ( line ) ; _dbContext . SaveChanges ( ) ; return true ; } return false ; }
removes an order line from the db; fails if line is not part of an order or if the order is already complete
removes an order line from the db ; fails if line is not part of an order or if the order is already complete
//restore quantity to inventory
None
line
OrderLine
None