Skip to content

Commit 37efcfa

Browse files
committed
implement UpdateEvent
Related to: aliencube#203
1 parent 99cfdec commit 37efcfa

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/AzureOpenAIProxy.ApiApp/Repositories/AdminEventRepository.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Azure.Data.Tables;
22

33
using AzureOpenAIProxy.ApiApp.Configurations;
4-
using AzureOpenAIProxy.ApiApp.Extensions;
54
using AzureOpenAIProxy.ApiApp.Models;
65

76
namespace AzureOpenAIProxy.ApiApp.Repositories;
@@ -65,18 +64,30 @@ public async Task<AdminEventDetails> GetEvent(Guid eventId)
6564
{
6665
TableClient tableClient = await GetTableClientAsync();
6766

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);
7268

73-
return eventDetail.Value;
69+
return eventDetails;
7470
}
7571

7672
/// <inheritdoc />
7773
public async Task<AdminEventDetails> UpdateEvent(Guid eventId, AdminEventDetails eventDetails)
7874
{
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;
8091
}
8192

8293
private async Task<TableClient> GetTableClientAsync()

0 commit comments

Comments
 (0)