コード例 #1
0
        public static AdvertType Map(AdvertConfirmedMessage message)
        {
            var doc = new AdvertType
            {
                Id               = message.Id,
                Title            = message.Title,
                CreationDateTime = DateTime.UtcNow
            };

            return(doc);
        }
コード例 #2
0
        public async Task Function(SNSEvent snsEvent, ILambdaContext context)
        {
            foreach (var record in snsEvent.Records)
            {
                context.Logger.LogLine(record.Sns.Message);

                AdvertConfirmedMessage message        = JsonConvert.DeserializeObject <AdvertConfirmedMessage>(record.Sns.Message);
                AdvertType             advertDocument = MappingHelper.Map(message);

                IndexResponse response = await _client.IndexDocumentAsync(advertDocument);

                context.Logger.LogLine("Result is " + response.Result.ToString());
                context.Logger.LogLine("Exception: " + response.OriginalException?.Message);
                context.Logger.LogLine("Server error: " + response.ServerError);
            }
        }