Beispiel #1
0
 private CashEntry UpdateItem(CashEntry oldCashEntry, CashEntry newCashEntry)
 {
     RemoveItem(oldCashEntry);
     return(new CashEntry
     {
         Denomination = newCashEntry.Denomination,
         Quantity = newCashEntry.Quantity
     });
 }
Beispiel #2
0
        public void Delete(CashEntry cashEntry)
        {
            if (cashEntry == null)
            {
                throw new ArgumentNullException();
            }

            RemoveItem(cashEntry);
            Save();
        }
Beispiel #3
0
        public void Insert(CashEntry cashEntry)
        {
            if (cashEntry == null)
            {
                throw new ArgumentNullException();
            }
            if (_items.Contains(cashEntry))
            {
                throw new ArgumentException("duplicate");
            }

            InsertItem(cashEntry);
            Save();
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 private void RemoveItem(CashEntry cashEntry) => _items.Remove(cashEntry);
Beispiel #6
0
 private void InsertItem(CashEntry cashEntry) => _items.Add(cashEntry);