private async Task PublishContact(Token token, ContactDetails contact)
        {
            var contactTopicArn = Environment.GetEnvironmentVariable("CONTACT_DETAILS_SNS_ARN");

            var createContactDetailsSnsMessage = _snsFactory.Create(contact, token, EventConstants.DELETED);

            await _snsGateway.Publish(createContactDetailsSnsMessage, contactTopicArn).ConfigureAwait(false);
        }
コード例 #2
0
        public async Task <PersonResponseObject> ExecuteAsync(CreatePersonRequestObject personRequestObject, Token token)
        {
            var person = await _gateway.PostNewPersonAsync(personRequestObject).ConfigureAwait(false);

            var personSnsMessage = _snsFactory.Create(person, token);
            var topicArn         = Environment.GetEnvironmentVariable("PERSON_SNS_ARN");
            await _snsGateway.Publish(personSnsMessage, topicArn).ConfigureAwait(false);

            return(_responseFactory.ToResponse(person));
        }
コード例 #3
0
        public async Task <ContactDetailsResponseObject> ExecuteAsync(ContactDetailsRequestObject contactRequest,
                                                                      Token token)
        {
            var dbObject = contactRequest.ToDomain(token).ToDatabase();
            var contact  = await _gateway.CreateContact(dbObject).ConfigureAwait(false);

            var contactTopicArn = Environment.GetEnvironmentVariable("CONTACT_DETAILS_SNS_ARN");

            var createContactDetailsSnsMessage = _snsFactory.Create(contact, token, EventConstants.CREATED);

            await _snsGateway.Publish(createContactDetailsSnsMessage, contactTopicArn).ConfigureAwait(false);

            return(contact.ToResponse());
        }
コード例 #4
0
        public async Task<PersonResponseObject> ExecuteAsync(UpdatePersonRequestObject personRequestObject, string requestBody,
            Token token, PersonQueryObject query, int? ifMatch)
        {
            var result = await _gateway.UpdatePersonByIdAsync(personRequestObject, requestBody, query, ifMatch).ConfigureAwait(false);
            if (result is null) return null;

            // Only raise the event if something actually changed.
            if (result.NewValues.Any())
            {
                var personSnsMessage = _snsFactory.Update(result, token);
                var topicArn = Environment.GetEnvironmentVariable("PERSON_SNS_ARN");
                await _snsGateway.Publish(personSnsMessage, topicArn).ConfigureAwait(false);
            }

            return _responseFactory.ToResponse(result.UpdatedEntity.ToDomain());
        }
コード例 #5
0
        public async Task PublishUpdate(WorkOrder workOrder)
        {
            _logger.LogInformation($"Starting PublishUpdate for work order {workOrder.Id}");

            var repairsTopicArn = Environment.GetEnvironmentVariable("REPAIRS_SNS_ARN");

            var tasks = await _repairsGateway.GetWorkOrderTasksForWorkOrder(workOrder);

            if (tasks == null || !tasks.Any())
            {
                throw new ArgumentException($"No tasks found for WorkOrder {workOrder.Id}");
            }

            List <EntityEventSns> snsMessages = await CreateMessages(workOrder, tasks);

            _logger.LogInformation($"About to publish {snsMessages.Count} messages for work order {workOrder.Id} completion");

            foreach (var message in snsMessages)
            {
                _logger.LogInformation($"Publishing {message.Id} work order {workOrder.Id} operative {message.EventData.OperativePrn}");
                await _snsGateway.Publish(message, repairsTopicArn);
            }
            return;
        }