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

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

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