Ejemplo n.º 1
0
    public async Task <OperationResult> Handle(RemoveTarefaCommand request, CancellationToken cancellationToken)
    {
        Tarefa obj = await _unitOfWork.TarefaRepository.GetAsync(request.Id);

        if (obj == null)
        {
            return(OperationResult.NotFound);
        }

        await _unitOfWork.TarefaRepository.RemoveAsync(request.Id);

        bool success = await _unitOfWork.SaveChangesAsync();

        OperationResult result = success ? OperationResult.Success : OperationResult.Failed;

        return(result);
    }
 public async UnaryResult <OperationResult> RemoveAsync(RemoveTarefaCommand command)
 {
     return(await _mediator.Send(command));
 }