Ejemplo n.º 1
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            var esa = new AvailableEndpoint
            {
                PartitionKey       = AliasBox.Text,
                RowKey             = "",
                alias              = AliasBox.Text,
                description        = DescriptionBox.Text,
                storageaccountname = tableStorageAccountNameBox.Text,
                storageaccountkey  = tableStorageAccountKeyBox.Text
            };

            if (DisclaimerBox.Text.Length > 0)
            {
                esa.disclaimer = DisclaimerBox.Text.Replace('\n', ' ');
            }

            var ta  = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
            var ctx = new OgdiConfigDataServiceContext(ta.TableEndpoint.AbsoluteUri, ta.Credentials);

            ctx.AddObject(OgdiConfigDataServiceContext.EndpointsTableName, esa);
            ctx.SaveChanges();

            DisplayLatest();
        }
Ejemplo n.º 2
0
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            var button = sender as LinkButton;

            string[] p            = button.CommandArgument.Split('|');
            var      partitionKey = p[0];
            var      rowKey       = p[1];

            var availableEndpoint = new AvailableEndpoint
            {
                PartitionKey = partitionKey,
                RowKey       = rowKey
            };

            var ta      = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
            var context = new OgdiConfigDataServiceContext(ta.TableEndpoint.AbsoluteUri, ta.Credentials);

            context.AttachTo(OgdiConfigDataServiceContext.EndpointsTableName, availableEndpoint, "*");
            context.DeleteObject(availableEndpoint);
            context.SaveChanges();

            DisplayLatest();
        }