Skip to content

Commit 3b749ed

Browse files
committed
req: Initializes Guests property correctly
Ensures that the Guests property is correctly initialized with adult and children counts. This change ensures correct population of guest groupings, which avoids potential errors or unexpected behavior when processing reservations.
1 parent 715d014 commit 3b749ed

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

libs/GuestLineSDK/Api/ReservationOperations.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,17 @@ public record ReservationRoom(
224224
[property: JsonIgnore] int Children)
225225
{
226226
[JsonPropertyName("GuestCount")]
227-
public ReservationGuestGrouping[]? Guests => GetGroupings().ToArray();
227+
public ReservationGuestGrouping[]? Guests { get; set; } = GetGroupings(Adults, Children).ToArray();
228228

229-
IEnumerable<ReservationGuestGrouping> GetGroupings()
229+
static IEnumerable<ReservationGuestGrouping> GetGroupings(int adults, int children)
230230
{
231-
if (Adults > 0)
231+
if (adults > 0)
232232
{
233-
yield return new ReservationGuestGrouping(10, Adults);
233+
yield return new ReservationGuestGrouping(10, adults);
234234
}
235-
if (Children > 0)
235+
if (children > 0)
236236
{
237-
yield return new ReservationGuestGrouping(8, Children);
237+
yield return new ReservationGuestGrouping(8, children);
238238
}
239239
}
240240
}

0 commit comments

Comments
 (0)