Esempio n. 1
0
        public ConfigEntity GetConfigByKey(string key)
        {

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "people" table.
            CloudTable table = tableClient.GetTableReference("config");

            // Create a retrieve operation that takes a customer entity.
            TableOperation retrieveOperation = TableOperation.Retrieve<ConfigEntity>(PARTITION_KEY, key);

            // Execute the retrieve operation.
            TableResult retrievedResult = table.Execute(retrieveOperation);
            ConfigEntity config = new ConfigEntity() { Value = "10" };
            if (retrievedResult.HttpStatusCode == 200)
            {
                config = (ConfigEntity)retrievedResult.Result;
            }


            return config;

        }
Esempio n. 2
0
        public void SaveConfigValue(string key, int value)
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "people" table.
            CloudTable table = tableClient.GetTableReference("config");

            // Create a new customer entity.
            var config = new ConfigEntity();
            config.PartitionKey = PARTITION_KEY;
            config.RowKey = key;
            config.Value = value.ToString();


            // Create the TableOperation object that inserts the customer entity.
            TableOperation insertOperation = TableOperation.InsertOrReplace(config);

            // Execute the insert operation.
            table.Execute(insertOperation);

        }
Esempio n. 3
0
 public ActionResult Save(ConfigEntity config)
 {
     int newValue = Convert.ToInt32(config.Value);
     SaveConfigValue(config.RowKey, newValue);
     return View("Index", config);
 }
Esempio n. 4
0
 public ActionResult Index(ConfigEntity config)
 {
     return Save(config);
 }