Ejemplo n.º 1
0
        public CommandResponse Handle(ApplyDebit command)
        {
            if (command.AccountId.IsSameOrEqualTo(Guid.Empty))
            {
                throw new InvalidOperationException("Cannot apply a debit with an empty account id.");
            }

            if (command.CorrelationId.IsSameOrEqualTo(Guid.Empty))
            {
                throw new InvalidOperationException("Cannot apply a debit with an empty correlation id.");
            }

            if (!_repo.TryGetById <Account>(command.AccountId, out var account))
            {
                throw new InvalidOperationException($"ApplyDebit: Account {{{command.AccountId}}} not found.");
            }

            account.ApplyDebit(command.AccountId, command.Amount, command.CorrelationId, command.MsgId);

            _repo.Save(account, Guid.NewGuid());
            return(command.Succeed());
        }
Ejemplo n.º 2
0
 public CommandResponse Handle(ApplyDebit command)
 {
     return(command.Succeed());
 }