Skip to content

Commit bf03d64

Browse files
api change
1 parent 7204eb1 commit bf03d64

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/ContosoSuitesWebAPI/Program.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,28 @@
5656
.WithOpenApi();
5757

5858
app.MapGet("/Hotels", async () =>
59-
{
60-
throw new NotImplementedException();
61-
})
62-
.WithName("GetHotels")
63-
.WithOpenApi();
59+
{
60+
var hotels = await app.Services.GetRequiredService<IDatabaseService>().GetHotels();
61+
return hotels;
62+
})
63+
.WithName("GetHotels")
64+
.WithOpenApi();
6465

6566
app.MapGet("/Hotels/{hotelId}/Bookings/", async (int hotelId) =>
66-
{
67-
throw new NotImplementedException();
68-
})
69-
.WithName("GetBookingsForHotel")
70-
.WithOpenApi();
67+
{
68+
var bookings = await app.Services.GetRequiredService<IDatabaseService>().GetBookingsForHotel(hotelId);
69+
return bookings;
70+
})
71+
.WithName("GetBookingsForHotel")
72+
.WithOpenApi();
7173

7274
app.MapGet("/Hotels/{hotelId}/Bookings/{min_date}", async (int hotelId, DateTime min_date) =>
73-
{
74-
throw new NotImplementedException();
75-
})
76-
.WithName("GetRecentBookingsForHotel")
77-
.WithOpenApi();
75+
{
76+
var bookings = await app.Services.GetRequiredService<IDatabaseService>().GetBookingsByHotelAndMinimumDate(hotelId, min_date);
77+
return bookings;
78+
})
79+
.WithName("GetRecentBookingsForHotel")
80+
.WithOpenApi();
7881

7982
app.MapPost("/Chat", async Task<string> (HttpRequest request) =>
8083
{

0 commit comments

Comments
 (0)