コード例 #1
0
        public async Task <Unit> Handle(DeleteToDoCommand request, CancellationToken cancellationToken)
        {
            var toDo = await _queryRepository.GetToDo(request.Id, request.Username);

            toDo.SetStatus(Status.Deleted);

            await _commandRepository.UpdateToDo(toDo);

            return(Unit.Value);
        }
コード例 #2
0
        public async Task <Unit> Handle(UpdateToDoCommand request, CancellationToken cancellationToken)
        {
            var toDo = await _queryRepository.GetToDo(request.Id, request.Username);

            toDo.SetDescription(request.Description);
            toDo.SetStatus(request.Status);

            await _commandRepository.UpdateToDo(toDo);

            await _mediator.Publish(new TaskUpdatedEvent(toDo.Username, toDo.Description, toDo.Status));

            return(Unit.Value);
        }