private async Task SendNotification(UpdatedContractStatusResponse updatedContractStatusResponse)
        {
            var notificationMessage = _mapper.Map <ContractNotification>(updatedContractStatusResponse);

            IDictionary <string, string> properties = new Dictionary <string, string>();

            switch (updatedContractStatusResponse.Action)
            {
            case ActionType.ContractConfirmApproval:
            case ActionType.ContractManualApproval:
                properties.Add("Status", MessageStatus.Approved.ToString("G"));
                break;

            case ActionType.ContractWithdrawal:
                properties.Add("Status", MessageStatus.Withdrawn.ToString("G"));
                break;

            case ActionType.ContractCreated:
                if (notificationMessage.Status == ContractStatus.Approved)
                {
                    properties.Add("Status", MessageStatus.ReadyToReview.ToString("G"));
                }
                else if (notificationMessage.Status == ContractStatus.PublishedToProvider)
                {
                    properties.Add("Status", MessageStatus.ReadyToSign.ToString("G"));
                }

                break;

            default:
                break;
            }

            if (properties.Count > 0)
            {
                _logger.LogInformation($"[SendNotification] Action type: {updatedContractStatusResponse.Action}, contract number: {notificationMessage.ContractNumber}, contract version: {notificationMessage.ContractVersion}, Contract is in {notificationMessage.Status.ToString("G")} status, Notification sending.");
                await _messagePublisher.PublisherAsync <ContractNotification>(notificationMessage, properties);

                _logger.LogInformation($"[SendNotification] Action type: {updatedContractStatusResponse.Action}, contract number: {notificationMessage.ContractNumber}, contract version: {notificationMessage.ContractVersion}, Contract is in {notificationMessage.Status.ToString("G")} status, Notification sent.");
            }
            else
            {
                _logger.LogInformation($"[SendNotification] Action type: {updatedContractStatusResponse.Action}, contract number: {notificationMessage.ContractNumber}, contract version: {notificationMessage.ContractVersion}, Contract is in {notificationMessage.Status.ToString("G")} status, Notification will not be sent.");
            }
        }
Esempio n. 2
0
 public async Task SendToProduct([FromBody] Product product)
 {
     await messagePublisher.PublisherAsync(product);
 }