/// <summary> /// Executes the Use Case. /// </summary> /// <param name="input">Input Message.</param> /// <returns>Task.</returns> public async Task Execute(GetAccountsInput input) { if (input is null) { this._getAccountsOutputPort .WriteError(Messages.InputIsNull); return; } IUser user = this._userService .GetUser(); List <IAccount> accounts = new List <IAccount>(); if (user.CustomerId is { } customerId) { accounts.AddRange(await this._accountRepository .GetBy(customerId) .ConfigureAwait(false)); } var output = new GetAccountsOutput(accounts); this._getAccountsOutputPort .Standard(output); }
public async Task <IActionResult> Get( [FromServices] IMediator mediator, [FromServices] GetAccountsPresenter presenter) { var input = new GetAccountsInput(); await mediator.PublishAsync(input) .ConfigureAwait(false); return(presenter.ViewModel); }