/// <summary> /// Creates or updates record in Azure Table Storage /// </summary> /// <typeparam name="T"></typeparam> /// <param name="resource"></param> /// <returns></returns> private async Task <T> CreateOrUpdate <T>(dynamic resource) where T : Resource, new() { var table = await Table(typeof(T)); var entity = new ResourceTableEntity((string)resource.Type, (string)resource.Id) { Resource = resource }; await table.ExecuteAsync(TableOperation.InsertOrReplace(entity)); return(await Get <T>(resource.Id)); }
/// <summary> /// Creates or updates record in Azure Table Storage /// </summary> /// <param name="type"></param> /// <param name="resource"></param> /// <returns></returns> private async Task <dynamic> CreateOrUpdate(Type type, dynamic resource) { var table = await Table((string)resource.Type); var entity = new ResourceTableEntity(type.Name, (string)resource.Id) { Resource = resource }; await table.ExecuteAsync(TableOperation.InsertOrReplace(entity)); return(await Get(type, resource.Id)); }
/// <summary> /// Gets a resource of a given type and with the provided id from a given table /// </summary> /// <param name="table"></param> /// <param name="typeName"></param> /// <param name="id"></param> /// <returns></returns> private async Task <dynamic> Get(CloudTable table, string typeName, string id) => await table.ExecuteRetrieveAsync(TableConfigProvider, typeName, ResourceTableEntity.IdToRowKey(id));