Пример #1
0
        public async Task <bool?> Handle(AddArrangementRequestCommand message, CancellationToken cancellationToken)
        {
            var request = message.ArrangementRequest;

            if (request == null)
            {
                return(null);
            }

            var application = await _applicationRepository.GetAsync(message.ApplicationNumber,
                                                                    "involved-parties,documents,arrangement-requests");

            if (application == null)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(application.ProductCode))
            {
                application.ProductCode = request.ProductCode;
                application.ProductName = request.ProductName;
            }

            await _requestRepository.AddArrangementRequestsToApplication(application, new List <ArrangementRequest>() { request });

            var messageObj = _messageEventFactory.CreateBuilder("offer", "product-selection-changed")
                             .AddHeaderProperty("application-number", application.ApplicationNumber);

            messageObj = messageObj.AddBodyProperty("product-code", application.ProductCode)
                         .AddBodyProperty("product-name", application.ProductName);
            _eventBus.Publish(messageObj.Build());
            return(true);
        }