Skip to content

Commit 99cfdec

Browse files
committed
implements update event details endpoint
Related to: aliencube#203
1 parent ca4cf2e commit 99cfdec

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,37 @@ public static RouteHandlerBuilder AddUpdateAdminEvent(this WebApplication app)
165165
{
166166
// Todo: Issue #19 https://github.com/aliencube/azure-openai-sdk-proxy/issues/19
167167
// Need authorization by admin
168-
var builder = app.MapPut(AdminEndpointUrls.AdminEventDetails, (
169-
[FromRoute] string eventId,
170-
[FromBody] AdminEventDetails payload) =>
168+
var builder = app.MapPut(AdminEndpointUrls.AdminEventDetails, async (
169+
[FromRoute] Guid eventId,
170+
[FromBody] AdminEventDetails payload,
171+
IAdminEventService service,
172+
ILoggerFactory loggerFactory) =>
171173
{
172-
// Todo: Issue #203 https://github.com/aliencube/azure-openai-sdk-proxy/issues/203
173-
return Results.Ok();
174+
var logger = loggerFactory.CreateLogger(nameof(AdminEventEndpoints));
175+
logger.LogInformation($"Received a request to update event details with ID: {eventId}");
176+
177+
if (payload is null)
178+
{
179+
logger.LogError("No payload found");
180+
181+
return Results.BadRequest("Payload is null");
182+
}
183+
184+
try
185+
{
186+
var result = await service.UpdateEvent(eventId, payload);
187+
188+
logger.LogInformation($"Update event details with ID: {eventId}");
189+
190+
return Results.Ok(result);
191+
}
192+
catch (Exception ex)
193+
{
194+
// need to add 404
195+
logger.LogError(ex, $"Failed to update event details with ID: {eventId}");
196+
197+
return Results.Problem(ex.Message, statusCode: StatusCodes.Status500InternalServerError);
198+
}
174199
})
175200
.Accepts<AdminEventDetails>(contentType: "application/json")
176201
.Produces<AdminEventDetails>(statusCode: StatusCodes.Status200OK, contentType: "application/json")

0 commit comments

Comments
 (0)