Ejemplo n.º 1
0
        public async Task <IActionResult> Update(string id, [FromBody] TodoItem item)
        {
            if (item == null || item.Uuid != id)
            {
                return(BadRequest());
            }

            var itemResponse = await DynamoClient.GetItemAsync(_tableName, new Dictionary <string, AttributeValue>
            {
                { "Uuid", new AttributeValue {
                      S = id
                  } }
            });

            if (!itemResponse.IsItemSet)
            {
                return(NotFound());
            }

            await DynamoClient.PutItemAsync(_tableName, new Dictionary <string, AttributeValue>
            {
                { "Uuid", new AttributeValue {
                      S = item.Uuid
                  } },
                { "Name", new AttributeValue {
                      S = item.Name
                  } },
                { "IsComplete", new AttributeValue {
                      N = item.IsComplete.ToString()
                  } }
            });

            return(new NoContentResult());
        }
Ejemplo n.º 2
0
 ///-------------------------------------------------------------------------------------------------
 /// <summary>   Sets the Skill's persistant session attributes in DynamoDB. </summary>
 ///
 /// <remarks>   Austin Wilson, 9/15/2018. </remarks>
 ///
 /// <param name="attributes">   The attributes to set. </param>
 /// <param name="callback">     The callback. </param>
 ///-------------------------------------------------------------------------------------------------
 public void SetSessionAttributes(Dictionary<string, AttributeValue> attributes, Action<SetSessionAttributesEventData> callback)
 {
     var playerItem = new Dictionary<string, AttributeValue>
     {
         {"id", new AttributeValue {S = alexaUserDynamoKey}},
         {"attributes", new AttributeValue {M = attributes}}
     };
     DynamoClient.PutItemAsync(tableName, playerItem, (result) =>
     {
         if (result.Exception == null)
         {
             if (debug)
             {
                 Debug.Log(displayName + "SetSessionAttributes " + result.Response.HttpStatusCode);
             }
             RaiseSetSessionAttributesResponseHandler(false, callback);
         }
         else
         {
             if (debug)
             {
                 Debug.LogError(displayName + "SetSessionAttributes: " + result.Exception.Message);
             }
             RaiseSetSessionAttributesResponseHandler(true, callback, result.Exception);
         }
     });
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([FromBody] TodoItem item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            item.Uuid = NewGuid().ToString();

            await DynamoClient.PutItemAsync(_tableName, new Dictionary <string, AttributeValue>
            {
                { "Uuid", new AttributeValue {
                      S = item.Uuid
                  } },
                { "Name", new AttributeValue {
                      S = item.Name
                  } },
                { "IsComplete", new AttributeValue {
                      N = item.IsComplete.ToString()
                  } }
            });

            return(CreatedAtRoute("GetTodo", new { id = item.Uuid }, item));
        }