|
1 | 1 | using Azure.Data.Tables; |
2 | 2 |
|
3 | 3 | using AzureOpenAIProxy.ApiApp.Configurations; |
4 | | -using AzureOpenAIProxy.ApiApp.Extensions; |
5 | 4 | using AzureOpenAIProxy.ApiApp.Models; |
6 | 5 |
|
7 | 6 | namespace AzureOpenAIProxy.ApiApp.Repositories; |
@@ -65,18 +64,30 @@ public async Task<AdminEventDetails> GetEvent(Guid eventId) |
65 | 64 | { |
66 | 65 | TableClient tableClient = await GetTableClientAsync(); |
67 | 66 |
|
68 | | - var eventDetail = await tableClient.GetEntityAsync<AdminEventDetails>( |
69 | | - rowKey: eventId.ToString(), |
70 | | - partitionKey: PartitionKeys.EventDetails |
71 | | - ).ConfigureAwait(false); |
| 67 | + var eventDetails = await GetEventDetailsAsync(eventId, tableClient); |
72 | 68 |
|
73 | | - return eventDetail.Value; |
| 69 | + return eventDetails; |
74 | 70 | } |
75 | 71 |
|
76 | 72 | /// <inheritdoc /> |
77 | 73 | public async Task<AdminEventDetails> UpdateEvent(Guid eventId, AdminEventDetails eventDetails) |
78 | 74 | { |
79 | | - throw new NotImplementedException(); |
| 75 | + TableClient tableClient = await GetTableClientAsync(); |
| 76 | + |
| 77 | + var previousDetails = await GetEventDetailsAsync(eventId, tableClient); |
| 78 | + |
| 79 | + await tableClient.UpdateEntityAsync<AdminEventDetails>(eventDetails, previousDetails.ETag); |
| 80 | + |
| 81 | + return eventDetails; |
| 82 | + } |
| 83 | + |
| 84 | + private async Task<AdminEventDetails> GetEventDetailsAsync(Guid eventId, TableClient tableClient) { |
| 85 | + var eventDetails = await tableClient.GetEntityAsync<AdminEventDetails>( |
| 86 | + rowKey: eventId.ToString(), |
| 87 | + partitionKey: PartitionKeys.EventDetails |
| 88 | + ).ConfigureAwait(false); |
| 89 | + |
| 90 | + return eventDetails.Value; |
80 | 91 | } |
81 | 92 |
|
82 | 93 | private async Task<TableClient> GetTableClientAsync() |
|
0 commit comments