public async Task Handle(DeleteTableInput input) { if (input is null) { outputPort.WriteError(Message.InputIsNull); return; } try { var table = await tableRepository.GetTableAsync(input.TableId, input.AccountId); foreach (var a in table.GetTasks()) { a.Delete(); } table.Delete(); await unitOfWork.Save(); BuildOutput(table); } catch (Exception e) { outputPort.WriteError(e.Message); } }
public async Task <IActionResult> Delete( [FromServices] IMediator mediator, [FromServices] DeleteTablePresenter presenter, [FromBody][Required] DeleteTableRequest request) { var accountId = this.HttpContext.User.Claims .FirstOrDefault(x => x.Type == "AccountId").Value; var input = new DeleteTableInput( new BaseEntityId(new Guid(accountId)), new BaseEntityId(request.TableId)); await mediator.PublishAsync(input); return(presenter.ViewModel); }