public void When(CustomerCreated e) { Created = true; Name = e.Name; Id = e.Id; Currency = e.Currency; Balance = new CurrencyAmount(0, e.Currency); }
public void AddTx(string name, CurrencyAmount change, CurrencyAmount balance, DateTime timeUtc) { Transactions.Add(new CustomerTransaction() { Name = name, Balance = balance, Change = change, TimeUtc = timeUtc }); }
public void AddPayment(string name, CurrencyAmount amount, DateTime utc) { Apply(new CustomerPaymentAdded() { Id = _state.Id, Payment = amount, NewBalance = _state.Balance + amount, PaymentName = name, Transaction = _state.MaxTransactionId + 1, TimeUtc = utc }); }
public void Charge(string name, CurrencyAmount amount) { Apply(new CustomerChargeAdded() { Id = _state.Id, Charge = amount, NewBalance = _state.Balance - amount, ChargeName = name, Transaction = _state.MaxTransactionId + 1, TimeUtc = DateTime.UtcNow }); }
public void Charge(string name, CurrencyAmount amount, DateTime time) { if (_state.Currency == Currency.None) throw new InvalidOperationException("Customer currency was not assigned!"); Apply(new CustomerChargeAdded() { Id = _state.Id, Charge = amount, NewBalance = _state.Balance - amount, ChargeName = name, Transaction = _state.MaxTransactionId + 1, TimeUtc = time }); }