public async Task Handle(ProcessFileUpdatedEvent message, CancellationToken token) { var processFile = await _processFileQueryRepository.Get(message.AggregateId, token); processFile.Handle(message); await _processFileCommandRepository.Update(processFile, token); await _processFileCommandRepository.SaveChanges(token); }
public async Task <bool> Handle(UpdateProcessFileCommand request, CancellationToken cancellationToken) { var processFile = await _processFileCommandRepository.Get(request.Id, cancellationToken); if (processFile == null || string.IsNullOrWhiteSpace(processFile.AggregateId)) { _logger.LogError($"Cannot update process file because it doesn't exist : '{request.Id}'"); throw new UnknownProcessFileException(request.Id); } processFile.Update(request.Name, request.Description); await _processFileCommandRepository.Update(processFile, cancellationToken); await _processFileCommandRepository.SaveChanges(cancellationToken); return(true); }
public async Task <PublishProcessFileResult> Handle(PublishProcessFileCommand request, CancellationToken cancellationToken) { var processFile = await _processFileCommandRepository.Get(request.Id, cancellationToken); if (request == null || string.IsNullOrWhiteSpace(processFile.AggregateId)) { throw new UnknownProcessFileException(request.Id); } var newProcessFile = processFile.Publish(); await _processFileCommandRepository.Update(processFile, cancellationToken); await _processFileCommandRepository.Add(newProcessFile, cancellationToken); await _processFileCommandRepository.SaveChanges(cancellationToken); return(new PublishProcessFileResult { Id = newProcessFile.AggregateId }); }