Esempio n. 1
0
        public async Task <ExpandoObject> FunctionHandler(APIGatewayProxyRequest input, ILambdaContext db)
        {
            HttpClient client = new HttpClient();

            string url = $"https://api.nasa.gov/planetary/apod?api_key=DcyC0NbDLkfedANtzI58asjhgNQWWHYozbs0yHeP";

            Table   pod     = Table.LoadTable(dbclient, tableName);
            NasaPOD podItem = JsonConvert.DeserializeObject <NasaPOD>(await client.GetStringAsync(url));


            PutItemOperationConfig config = new PutItemOperationConfig();

            config.ReturnValues = ReturnValues.AllOldAttributes;

            await pod.PutItemAsync(Document.FromJson(JsonConvert.SerializeObject(podItem)), config);

            return(JsonConvert.DeserializeObject <ExpandoObject>(await client.GetStringAsync(url)));
        }
Esempio n. 2
0
        public async Task TestGetTitleFromDB()
        {
            string id = "2021-04-30";

            GetItemResponse res = await dbclient.GetItemAsync(tableName, new Dictionary <string, AttributeValue>
            {
                {
                    "date", new AttributeValue {
                        S = id
                    }
                }
            });


            Document myDoc = Document.FromAttributeMap(res.Item);
            NasaPOD  pod   = JsonConvert.DeserializeObject <NasaPOD>(myDoc.ToJson());


            string title = "Pink and the Perigee Moon";

            Assert.Equal(title, pod.title);
        }