private void UpdateStock()

in saga-orchestration/RevertInventoryLambda/src/RevertInventoryLambda/Function.cs [36:59]


        private void UpdateStock(string ItemId, ILambdaContext context)
        {
            var updateRequest = new UpdateItemRequest()
            {
                TableName = tableName,
                Key = new Dictionary<string, AttributeValue>
                {
                    { "ItemId", new AttributeValue { S =ItemId } }
                },
                ExpressionAttributeValues = new Dictionary<string, AttributeValue>
                {
                    { ":inc", new AttributeValue { N = "1" } }
                },
                UpdateExpression = "SET ItemsInStock = ItemsInStock + :inc",
                ReturnValues = "ALL_NEW"
            };
            var response = client.UpdateItemAsync(updateRequest);

            // Check the response.
            var attributeList = response.Result.Attributes; // attribute list in the response.
            // print attributeList.
            Console.WriteLine("\nPrinting item after incrementing stock  ............");
            PrintItem(attributeList,context);
        }