private CashEntry UpdateItem(CashEntry oldCashEntry, CashEntry newCashEntry) { RemoveItem(oldCashEntry); return(new CashEntry { Denomination = newCashEntry.Denomination, Quantity = newCashEntry.Quantity }); }
public void Delete(CashEntry cashEntry) { if (cashEntry == null) { throw new ArgumentNullException(); } RemoveItem(cashEntry); Save(); }
public void Insert(CashEntry cashEntry) { if (cashEntry == null) { throw new ArgumentNullException(); } if (_items.Contains(cashEntry)) { throw new ArgumentException("duplicate"); } InsertItem(cashEntry); Save(); }
public CashEntry Update(CashEntry cashEntry) { if (cashEntry == null) { throw new ArgumentNullException(); } var item = _items.FirstOrOptional(i => i.Equals(cashEntry)); var itemToInsert = item.Handle(i => UpdateItem(i, cashEntry), () => cashEntry); InsertItem(itemToInsert); Save(); return(itemToInsert); }
private void RemoveItem(CashEntry cashEntry) => _items.Remove(cashEntry);
private void InsertItem(CashEntry cashEntry) => _items.Add(cashEntry);