public async Task <IActionResult> Create( [FromServices] IMediator mediator, [FromServices] CreateTablePresenter presenter, [FromBody][Required] CreateTableRequest request) { var accountId = this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "AccountId").Value; var input = new CreateTableInput( new TableTitle(request.TableName), new BaseEntityId(new Guid(accountId))); await mediator.PublishAsync(input); return(presenter.ViewModel); }
public async Task Handle(CreateTableInput input) { if (input is null) { outputPort.WriteError(Message.InputIsNull); return; } try { var account = await accountRepository.GetAccountAsync(input.AccountId); var table = await tableService.CreateTable(input.TableName, account); await unitOfWork.Save(); BuildOutput(table); } catch (Exception e) { outputPort.WriteError(e.Message); } }