public async Task <CloseResult> Process(CloseCommand command) { Account account = await accountReadOnlyRepository.Get(command.AccountId); account.Close(); await accountWriteOnlyRepository.Delete(account); CloseResult result = resultConverter.Map <CloseResult>(account); return(result); }
public async Task <CloseResult> Handle(CloseCommand command) { Customer customer = await customerReadOnlyRepository.GetByAccount(command.AccountId); Account account = customer.FindAccount(command.AccountId); customer.RemoveAccount(command.AccountId); await customerWriteOnlyRepository.Update(customer); CloseResult response = resultConverter.Map <CloseResult>(account); return(response); }
public async Task <CloseResult> Process(CloseCommand command) { Account account = await accountReadOnlyRepository.Get(command.AccountId); if (account == null) { throw new AccountNotFoundException($"The account {command.AccountId} does not exists or is already closed."); } account.Close(); await accountWriteOnlyRepository.Delete(account); CloseResult result = new CloseResult(account); return(result); }