コード例 #1
0
        public async Task DeleteAsync(IPracticePlan practicePlan)
        {
            var partitionKey = PracticePlanEntity.GetPartitionKey();
            var rowKey       = PracticePlanEntity.GetRowKey(practicePlan);
            var cloudTable   = await this.cloudTableFactory.CreateAsync(PracticePlanTableName);

            var tableOperation = TableOperation.Retrieve(partitionKey, rowKey);
            var result         = await cloudTable.ExecuteAsync(tableOperation);

            if (result?.Result != null && result.Result is ITableEntity)
            {
                tableOperation = TableOperation.Delete((ITableEntity)result.Result);
                await cloudTable.ExecuteAsync(tableOperation);
            }
        }
コード例 #2
0
        public async Task <IPracticePlan> UpsertAsync(IPracticePlan practicePlan)
        {
            var entity = new PracticePlanEntity
            {
                StartDate    = practicePlan.StartDate,
                Details      = practicePlan.Details,
                PartitionKey = PracticePlanEntity.GetPartitionKey(),
                RowKey       = PracticePlanEntity.GetRowKey(practicePlan)
            };

            var cloudTable = await this.cloudTableFactory.CreateAsync(PracticePlanTableName);

            var tableOperation = TableOperation.InsertOrMerge(entity);
            var result         = await cloudTable.ExecuteAsync(tableOperation);

            return(new PracticePlanDto((PracticePlanEntity)result.Result));
        }