private void BuildOutput(IAccount account) { var closeAccountOutput = new CloseAccountOutput(account); this._closeAccountOutputPort .Standard(closeAccountOutput); }
public async Task Execute(CloseAccountInput closeAccountInput) { IAccount account = await _accountRepository.Get(closeAccountInput.AccountId); if (account == null) { _outputHandler.Error($"The account '{closeAccountInput.AccountId}' does not exist or is already closed."); return; } if (account.IsClosingAllowed()) { await _accountRepository.Delete(account); // Publish the event to the enterprice service bus await _serviceBus.PublishEventAsync(new Shared.Events.CloseAccountCompleted() { AccountId = account.Id }); await _unitOfWork.Save(); } var closeAccountOutput = new CloseAccountOutput(account); _outputHandler.Default(closeAccountOutput); }
public async Task Execute(CloseAccountInput closeAccountInput) { IAccount account = await _accountRepository.Get(closeAccountInput.AccountId); if (account == null) { _outputHandler.Error($"The account {closeAccountInput.AccountId} does not exist or is already closed."); return; } if (account.IsClosingAllowed()) { await _accountRepository.Delete(account); } var closeAccountOutput = new CloseAccountOutput(account); _outputHandler.Default(closeAccountOutput); }
/// <summary> /// Executes the Use Case. /// </summary> /// <param name="input">Input Message.</param> /// <returns>Task.</returns> public async Task Execute(CloseAccountInput input) { if (input is null) { this._closeAccountOutputPort .WriteError(Messages.InputIsNull); return; } IAccount account = await this._accountRepository .GetAccount(input.AccountId) .ConfigureAwait(false); if (account is null) { this._closeAccountOutputPort .NotFound(Messages.AccountDoesNotExist); return; } if (account.IsClosingAllowed()) { await this._accountRepository .Delete(account) .ConfigureAwait(false); } else { this._closeAccountOutputPort .WriteError(Messages.AccountHasFunds); return; } var closeAccountOutput = new CloseAccountOutput(account); this._closeAccountOutputPort .Standard(closeAccountOutput); }
public void Standard(CloseAccountOutput output) => this.ClosedAccounts.Add(output);
public void Standard(CloseAccountOutput closeAccountOutput) { ViewModel = new OkObjectResult(closeAccountOutput.AccountId); }
public void Default(CloseAccountOutput output) => ClosedAccounts.Add(output);
public void Standard(CloseAccountOutput closeAccountOutput) { ViewModel = new OkResult(); }
public void Default(CloseAccountOutput closeAccountOutput) { ViewModel = new OkResult(); }
public CloseAccountResponse(CloseAccountOutput output) { AccountId = output.AccountId.ToGuid(); }
/// <summary> /// Standard Output /// </summary> /// <param name="output">Output message.</param> public void Standard(CloseAccountOutput output) => this.StandardOutput = output;
public CloseAccountResponse(CloseAccountOutput output) { AccountId = output.AccountId; }
public void Standard(CloseAccountOutput output) { ClosedAccounts.Add(output); }
private void BuildOutput(IAccount account) { var closeAccountOutput = new CloseAccountOutput(account); _outputHandler.Standard(closeAccountOutput); }
public CloseAccountResponse(CloseAccountOutput output) => this.AccountId = output.Account.Id.ToGuid();
/// <summary> /// Produces the Standard result. /// </summary> /// <param name="output">Output.</param> public void Standard(CloseAccountOutput output) => this.ViewModel = new OkObjectResult(output.Account.Id);