public async Task Consume(ConsumeContext <CaseFilePublishedEvent> context) { var caseFile = await _caseFileCommandRepository.Get(context.Message.AggregateId, CancellationToken.None); var tDefinitions = CMMNParser.ParseWSDL(caseFile.Payload); foreach (var casePlan in CMMNParser.ExtractCasePlans(tDefinitions, caseFile)) { await _casePlanCommandRepository.Add(casePlan, CancellationToken.None); } await _casePlanCommandRepository.SaveChanges(CancellationToken.None); }
public async Task <bool> Handle(UpdateCaseFilePayloadCommand request, CancellationToken cancellationToken) { var caseFile = await _caseFileCommandRepository.Get(request.Id, cancellationToken); if (caseFile == null || string.IsNullOrWhiteSpace(caseFile.AggregateId)) { throw new UnknownCaseFileException(request.Id); } caseFile.UpdatePayload(request.Payload); await _caseFileCommandRepository.Update(caseFile, cancellationToken); await _caseFileCommandRepository.SaveChanges(cancellationToken); return(true); }
public async Task <bool> Handle(UpdateCaseFileCommand command, CancellationToken token) { var caseFile = await _caseFileCommandRepository.Get(command.Id, token); if (caseFile == null || string.IsNullOrWhiteSpace(caseFile.AggregateId)) { throw new UnknownCaseFileException(command.Id); } caseFile.Update(command.Name, command.Description); await _caseFileCommandRepository.Update(caseFile, token); await _caseFileCommandRepository.SaveChanges(token); return(true); }
public async Task <string> Handle(PublishCaseFileCommand publishCaseFileCommand, CancellationToken token) { var caseFile = await _caseFileCommandRepository.Get(publishCaseFileCommand.Id, token); if (caseFile == null || string.IsNullOrWhiteSpace(caseFile.AggregateId)) { throw new UnknownCaseFileException(publishCaseFileCommand.Id); } var newCaseFile = caseFile.Publish(); await _caseFileCommandRepository.Update(caseFile, token); await _caseFileCommandRepository.Add(newCaseFile, token); await _caseFileCommandRepository.SaveChanges(token); await _busControl.Publish(caseFile.DomainEvents.First() as CaseFilePublishedEvent, token); return(newCaseFile.AggregateId); }