コード例 #1
0
        public async Task Handle(CaseFileAddedEvent @event, CancellationToken cancellationToken)
        {
            var caseFile = Domains.CaseFileAggregate.New(new List <DomainEvent>
            {
                @event
            });
            await _caseFileCommandRepository.Add(caseFile, cancellationToken);

            await _caseFileCommandRepository.SaveChanges(cancellationToken);
        }
コード例 #2
0
        public async Task <CreateCaseFileResult> Handle(AddCaseFileCommand addCaseFileCommand, CancellationToken token)
        {
            var payload = addCaseFileCommand.Payload;

            if (string.IsNullOrWhiteSpace(addCaseFileCommand.Payload))
            {
                payload = _options.DefaultCMMNSchema;
                payload = payload.Replace("{id}", $"CasePlanModel_{Guid.NewGuid()}");
            }

            var caseFile = CaseFileAggregate.New(addCaseFileCommand.Name, addCaseFileCommand.Description, 0, payload);
            await _caseFileCommandRepository.Add(caseFile, token);

            await _caseFileCommandRepository.SaveChanges(token);

            return(new CreateCaseFileResult
            {
                Id = caseFile.AggregateId
            });
        }
コード例 #3
0
        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);
        }