Beispiel #1
0
 public Task UpdateTableAsync(TableSchema tableSchema)
 {
     return CreateOrUpdateTableAsync(HttpMethod.Put, tableSchema);
 }
 public Task<bool> CreateTableAsync(TableSchema tableSchema)
 {
     return CreateOrUpdateTableAsync(HttpMethod.Post, tableSchema);
 }
Beispiel #3
0
        private async Task CreateOrUpdateTableAsync(HttpMethod httpMethod, TableSchema tableSchema)
        {
            if (tableSchema == null)
            {
                throw new ArgumentNullException("tableSchema");
            }

            IHttpAddress address = baseAddress.WithResource( "_schema");

            var tableSchemas = new { table = new List<TableSchema> { tableSchema } };
            string body = contentSerializer.Serialize(tableSchemas);
            IHttpRequest request = new HttpRequest(httpMethod, address.Build(), baseHeaders, body);

            IHttpResponse response = await httpFacade.RequestAsync(request);
            HttpUtils.ThrowOnBadStatus(response, contentSerializer);
        }
        private async Task<bool> CreateOrUpdateTableAsync(HttpMethod httpMethod, TableSchema tableSchema)
        {
            if (tableSchema == null)
            {
                throw new ArgumentNullException("tableSchema");
            }

            SuccessResponse result = await base.RequestWithPayloadAsync<RequestResourceWrapper<TableSchema>, SuccessResponse>(
                method: httpMethod,
                resource: "_schema",
                query: null,
                payload: new RequestResourceWrapper<TableSchema> { Records = new List<TableSchema>(new [] { tableSchema }) }
                );

            return result.Success ?? false;
        }