Пример #1
0
        public async Task <bool?> Handle(DeleteArrangementRequestCommand message, CancellationToken cancellationToken)
        {
            ArrangementRequest arrangementRequest;

            arrangementRequest = _arrangementRequestRepository.GetArrangementRequest(message.ApplicationNumber,
                                                                                     message.ArrangementRequestId, "product-snapshot", null);
            if (arrangementRequest == null)
            {
                return(null);
            }
            var requestsToDelete = _arrangementRequestRepository.GetBundledRequests(arrangementRequest, false);

            requestsToDelete.Add(arrangementRequest);
            var result = await _arrangementRequestRepository.DeleteArrangementRequests(message.ApplicationNumber, requestsToDelete);

            var application = await _applicationRepository.GetAsync(message.ApplicationNumber);

            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());

            await _auditClient.WriteLogEntry(AuditLogEntryAction.Delete, AuditLogEntryStatus.Success, "arrangement", message.ApplicationNumber.ToString(), "Arrangement deleted " + arrangementRequest.ArrangementRequestId, new { });

            return(result);
        }