コード例 #1
0
        public async Task Handle(CaseFileUpdatedEvent @event, CancellationToken cancellationToken)
        {
            var caseFile = await _caseFileQueryRepository.Get(@event.AggregateId, cancellationToken);

            caseFile.Handle(@event);
            await _caseFileCommandRepository.Update(caseFile, cancellationToken);

            await _caseFileCommandRepository.SaveChanges(cancellationToken);
        }
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
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);
        }