public async Task Execute(Input input) { Guid AccountId; var result = CommonAccess.GetAccessAccount(input.AccountId, _accountRepository, _loginUserService).Result.ToString(); if (!Guid.TryParse(result, out AccountId)) { _outputHandler.Error(result); return; } IAccount account = await _accountRepository.Get(AccountId); if (account == null) { _outputHandler.Error($"The account {input.AccountId} does not exists or is already closed."); return; } ICredit credit = account.Deposit(input.Amount); await _accountRepository.Update(account, credit); Output output = new Output( credit, account.GetCurrentBalance()); _outputHandler.Handle(output); }
public async Task Execute(Input input) { Guid AccountId; var result = CommonAccess.GetAccessAccount(input.AccountId, _accountRepository, _loginUserService).Result.ToString(); if (!Guid.TryParse(result, out AccountId)) { _outputHandler.Error(result); return; } IAccount account = await _accountRepository.Get(AccountId); if (account == null) { _outputHandler.Error($"The account {input.AccountId} does not exists or is already closed."); return; } if (account.IsClosingAllowed()) { await _accountRepository.Delete(account); } var output = new Output(account); _outputHandler.Handle(output); }