I have to store at least 3 user credentials(username, password) into the DynamoDB table, but I cannot find how to create and store multiple user credentials with this code. I created just one credential using this code and my goal is to add multiple credentials into the same table that I created. Thank you in advance.
public async void InsertItem()
{
PutItemRequest request = new PutItemRequest
{
TableName = tableName,
Item = new Dictionary<string, AttributeValue>
{
{"Username", new AttributeValue{S="[email protected]"} },
{"Password", new AttributeValue{S="1234"} }
}
};
try
{
var response = await client.PutItemAsync(request);
if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) MessageBox.Show("Item added successfully!");
}
catch (InternalServerErrorException iee)
{
MessageBox.Show("An error occurred on the server side" + iee.Message);
}
catch (ResourceNotFoundException ex)
{
MessageBox.Show("The operation tried to access a nonexistent table or index.");
}
}
public async void GetItem()
{
GetItemRequest request = new GetItemRequest
{
TableName = tableName,
Key = new Dictionary<string, AttributeValue>
{
{"Username", new AttributeValue{S="[email protected]"} },
{"Password", new AttributeValue{S="1234"} }
}
};
try
{
var response = await client.GetItemAsync(request);
if(response.HttpStatusCode == System.Net.HttpStatusCode.OK)
{
if (response.Item.Count > 0)
{
MessageBox.Show("Item(s) retrieved successfully");
foreach (var item in response.Item) ;
}
}
}
catch (InternalServerErrorException iee)
{
MessageBox.Show("An error occurred on the server side" + iee.Message);
}
catch (ResourceNotFoundException ex)
{
MessageBox.Show("The operation tried to access a nonexistent table or index.");
}
}