public void Update(AmountTransferedEvent @event) { if (@event.EventDate <= _archive.LastEventDate) { return; } var benefactor = _archive.GetAccount(@event.BenefactorAccountId).ValueOrDefault(null); var recipient = _archive.GetAccount(@event.ReceipientAccountId).ValueOrDefault(null); var debit = new Debit(@event.ReceipientAccountId, @event.Amount, @event.Description, @event.EventDate); var credit = new Credit(@event.BenefactorAccountId, @event.Amount, @event.Description, @event.EventDate); benefactor.AddTransaction(debit); recipient.AddTransaction(credit); _archive.LastEventDate = @event.EventDate; }
public decimal Handle(GetCreditLimitForAccountIdQuery query) { var account = _archive.GetAccount(query.Account); if (!account.HasValue()) { return(0); } return(account.ValueOrDefault(null).creditLimit); }
public decimal Handle(GetDisposableAmountQuery query) { var maybeAccount = _archive.GetAccount(query.AccountId); if (maybeAccount.HasValue()) { var account = maybeAccount.ValueOrDefault(null); return(_archive.GetBalance(query.AccountId).ValueOrDefault(0) + account.creditLimit); } return(0); }
public IEnumerable <TransferDto> Handle(GetStatementQuery query) { var maybeAccount = _archive.GetAccount(query.account); if (maybeAccount.HasValue()) { var account = maybeAccount.ValueOrDefault(null); foreach (var transaction in account.GetTransactions()) { var visitor = _visitorFactory.CreateVisitor(account.CustomerId); yield return(transaction.Accept(visitor)); } } }
public void Update(CreditLimitChangedEvent @event) { if (@event.EventDate <= _archive.LastEventDate) { return; } var account = _archive.GetAccount(@event.AccountId); if (account.HasValue()) { account.ValueOrDefault(null).creditLimit = @event.CreditLimit; } _archive.LastEventDate = @event.EventDate; }
public Guid Handle(GetCustomerIdByAccountIdQuery query) { return(_archive.GetAccount(query.Account).ValueOrDefault(null).CustomerId); }