private void AddNewEntryToTransaction() { foreach (var line in _parentVM.DisplayedLines) { if (!_newEntryItem.ID.Equals(line.Item.ID) || !_newEntryWarehouse.ID.Equals(line.Warehouse.ID) || !_newEntryPrice.Equals(line.PurchasePrice) || !_newEntryDiscount.Equals(line.Discount)) { continue; } Debug.Assert(_newEntryQuantity != null, "_newEntryQuantity != null"); line.Quantity += (int)_newEntryQuantity; ResetEntryFields(); return; } Debug.Assert(_newEntryQuantity != null, "_newEntryQuantity != null"); var newEntryLine = new PurchaseTransactionLine { Quantity = (int)_newEntryQuantity, PurchasePrice = _newEntryPrice, Discount = _newEntryDiscount, Item = _newEntryItem.Model, Warehouse = _newEntryWarehouse.Model, SoldOrReturned = 0, PurchaseTransaction = _parentVM.Model, Total = (int)_newEntryQuantity * (_newEntryPrice - _newEntryDiscount) }; var lineVM = new PurchaseTransactionLineVM { Model = newEntryLine }; _parentVM.DisplayedLines.Add(lineVM); }
private void AddNewEntryToTransaction() { foreach (var line in _parentVM.DisplayedLines) { if (!_newEntryItem.ID.Equals(line.Item.ID) || !_newEntryWarehouse.ID.Equals(line.Warehouse.ID) || !_newEntryPrice.Equals(line.PurchasePrice) || !_newEntryDiscount.Equals(line.Discount)) continue; Debug.Assert(_newEntryQuantity != null, "_newEntryQuantity != null"); line.Quantity += (int) _newEntryQuantity; ResetEntryFields(); return; } Debug.Assert(_newEntryQuantity != null, "_newEntryQuantity != null"); var newEntryLine = new PurchaseTransactionLine { Quantity = (int)_newEntryQuantity, PurchasePrice = _newEntryPrice, Discount = _newEntryDiscount, Item = _newEntryItem.Model, Warehouse = _newEntryWarehouse.Model, SoldOrReturned = 0, PurchaseTransaction = _parentVM.Model, Total = (int)_newEntryQuantity * (_newEntryPrice - _newEntryDiscount) }; var lineVM = new PurchaseTransactionLineVM { Model = newEntryLine }; _parentVM.DisplayedLines.Add(lineVM); }