in dotnetv3/dynamodb/FromSQL/UpdateItemExample/UpdateItemExample/UpdateItem.cs [26:98]
public static async Task Main(string[] args)
{
var configfile = "app.config";
var region = string.Empty;
var table = string.Empty;
var id = string.Empty;
var status = string.Empty;
// Get default Region and table from config file
var efm = new ExeConfigurationFileMap
{
ExeConfigFilename = configfile,
};
Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(efm, ConfigurationUserLevel.None);
if (configuration.HasFile)
{
AppSettingsSection appSettings = configuration.AppSettings;
region = appSettings.Settings["Region"].Value;
table = appSettings.Settings["Table"].Value;
if ((region == string.Empty) || (table == string.Empty))
{
Console.WriteLine("You must specify a Region and Table value in " + configfile);
return;
}
}
else
{
Console.WriteLine("Could not find " + configfile);
return;
}
int i = 0;
while (i < args.Length)
{
switch (args[i])
{
case "-i":
i++;
id = args[i];
break;
case "-s":
i++;
status = args[i];
break;
}
i++;
}
if ((status == string.Empty) || (id == string.Empty) || ((status != "backordered") && (status != "delivered") && (status != "delivering") && (status != "pending")))
{
Console.WriteLine("You must supply a partition number (-i ID), and status value (-s STATUS) of backordered, delivered, delivering, or pending");
return;
}
var newRegion = RegionEndpoint.GetBySystemName(region);
IAmazonDynamoDB client = new AmazonDynamoDBClient(newRegion);
// Silenty ignores issue if id does not identify an order
var response = await ModifyOrderStatusAsync(client, table, id, status);
if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
{
Console.WriteLine("Successfully updated item in " + table + " in region " + region);
}
else
{
Console.WriteLine("Could not update order status");
}
}