public async Task <IActionResult> ChangeTitle(
            [FromServices] IMediator mediator,
            [FromServices] ChangeTableTitlePresenter presenter,
            [FromBody][Required] ChangeTableTitleRequest request)
        {
            var accountId = this.HttpContext.User.Claims
                            .FirstOrDefault(x => x.Type == "AccountId").Value;

            var input = new ChangeTableTitleInput(
                new BaseEntityId(new Guid(accountId)),
                new BaseEntityId(request.TableId),
                new TableTitle(request.Title));

            await mediator.PublishAsync(input);

            return(presenter.ViewModel);
        }
Beispiel #2
0
        public async Task Handle(ChangeTableTitleInput input)
        {
            if (input is null)
            {
                outputPort.WriteError(Message.InputIsNull);
                return;
            }

            try
            {
                var table = await tableRepository.GetTableAsync(input.TableId, input.AccountId);

                table.ChangeName(input.Title);
                await unitOfWork.Save();

                BuildOutput(table);
            }
            catch (Exception e)
            {
                outputPort.WriteError(e.Message);
            }
        }