public async Task <UserEntity> InsertOrMergeEntityAsync(CloudTable table, UserEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } try { // Create the InsertOrReplace table operation var insertOrMergeOperation = TableOperation.InsertOrMerge(entity); // Execute the operation. var result = await table.ExecuteAsync(insertOrMergeOperation); var insertedCustomer = result.Result as UserEntity; if (result.RequestCharge.HasValue) { _logger.LogInformation("Request Charge of InsertOrMerge Operation: " + result.RequestCharge); } return(insertedCustomer); } catch (StorageException e) { _logger.LogError(e.Message); Console.ReadLine(); throw; } }
public async Task DeleteEntityAsync(CloudTable table, UserEntity deleteEntity) { try { if (deleteEntity == null) { throw new ArgumentNullException(nameof(deleteEntity)); } var deleteOperation = TableOperation.Delete(deleteEntity); var result = await table.ExecuteAsync(deleteOperation); if (result.RequestCharge.HasValue) { _logger.LogInformation("Request Charge of Delete Operation: " + result.RequestCharge); } } catch (StorageException e) { _logger.LogError(e.Message); throw; } }