コード例 #1
0
        public async Task HandleAsync(CreateDataEntry message, IRequestInfo requestInfo)
        {
            SpecificationDocument specificationDocument;
            var order = await _repository.GetNextOrderNumberAsync(message.BusinessId);

            try
            {
                specificationDocument =
                    _aggregate.Create(message.Label, order, message.ValidationMessage, message.ValidationCode, message.BusinessId);
            }
            catch (VmsException e)
            {
                _publisher.PublishEvent(new DataSpecificationRejected(e.Code, e.Message), requestInfo);
                _logger.LogWarning(e.Message, LoggingCategories.DomainValidation);
                return;
            }

            await _repository.AddAsync(specificationDocument);

            _publisher.PublishEvent(new DataSpecificationCreated(), requestInfo);
            _logger.LogInformation($"Data specification labeled {message.Label} created with id: {specificationDocument.Id}");
        }