コード例 #1
0
        public async Task <Unit> Handle(TarefaDeleteCommand request, CancellationToken cancellationToken)
        {
            var tarefaEntity = tarefaDomainService.Get(request.TarefaId, request.UsuarioId);

            //excluindo no dominio (sqlserver)
            tarefaDomainService.Delete(tarefaEntity);

            //excluindo no mongodb
            await mediator.Publish(new TarefaNotification
            {
                Tarefa = tarefaEntity,
                Action = ActionNotification.Delete
            });

            return(Unit.Value);
        }
コード例 #2
0
        public async Task <IActionResult> Delete(Guid tarefaId, Guid usuarioId)
        {
            try
            {
                var command = new TarefaDeleteCommand {
                    TarefaId = tarefaId, UsuarioId = usuarioId
                };

                await tarefaApplicationService.Delete(command);

                return(StatusCode(200, new
                {
                    message = "Tarefa excluída com sucesso."
                }));
            }
            catch (Exception e)
            {
                return(StatusCode(500, new
                {
                    e.Message
                }));
            }
        }
コード例 #3
0
 public async Task Delete(TarefaDeleteCommand command)
 {
     await mediator.Send(command);
 }