Skip to content

Commit

Permalink
Feature/remove remainingattendeecapacity from b (#229)
Browse files Browse the repository at this point in the history
* feat: remove remainingAttendeeCapacity and maximumAttendeeCapacity from B response

* remove from P response too
  • Loading branch information
civsiv authored Apr 3, 2024
1 parent 1c99ae8 commit a98b8da
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,13 @@ public static void AddPropertiesToBookedOrderItem(IOrderItemContext ctx, BookedO
}
}

public static void RemovePropertiesFromBookedOrderItem(IOrderItemContext ctx)
{
// Set RemainingAttendeeCapacity and MaximumAttendeeCapacity to null as the do not belong in the B and P responses.
// For more information see: https://github.com/openactive/open-booking-api/issues/156#issuecomment-926643733
ctx.ResponseOrderItem.OrderedItem.Object.RemainingAttendeeCapacity = null;
ctx.ResponseOrderItem.OrderedItem.Object.MaximumAttendeeCapacity = null;
}

}
}
4 changes: 4 additions & 0 deletions Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ protected override async ValueTask BookOrderItems(List<OrderItemContext<Facility
// Set OrderItemId and access properties for each orderItemContext
ctx.SetOrderItemId(flowContext, bookedOrderItemInfo.OrderItemId);
BookedOrderItemHelper.AddPropertiesToBookedOrderItem(ctx, bookedOrderItemInfo);
// Remove attendee capacity information from the OrderedItem. For more information see: https://github.com/openactive/open-booking-api/issues/156#issuecomment-926643733
BookedOrderItemHelper.RemovePropertiesFromBookedOrderItem(ctx);
}
break;
case ReserveOrderItemsResult.SellerIdMismatch:
Expand Down Expand Up @@ -621,6 +623,8 @@ protected override async ValueTask ProposeOrderItems(List<OrderItemContext<Facil
foreach (var (ctx, bookedOrderItemInfo) in ctxGroup.Zip(bookedOrderItemInfos, (ctx, bookedOrderItemInfo) => (ctx, bookedOrderItemInfo)))
{
ctx.SetOrderItemId(flowContext, bookedOrderItemInfo.OrderItemId);
// Remove attendee capacity information from the OrderedItem. For more information see: https://github.com/openactive/open-booking-api/issues/156#issuecomment-926643733
BookedOrderItemHelper.RemovePropertiesFromBookedOrderItem(ctx);
}
break;
case ReserveOrderItemsResult.SellerIdMismatch:
Expand Down
6 changes: 5 additions & 1 deletion Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ protected override async ValueTask LeaseOrderItems(
}
}
}
// TODO: This should reuse code of LeaseOrderItem to be DRY. Similar logic is also used in ProposeOrderItems as well as
// TODO: This should reuse code of LeaseOrderItem to be DRY. Similar logic is also used in ProposeOrderItems as well as
// in LeaseOrderItems, BookOrderItems, and ProposeOrderItems in the SessionStore. The issue for this is: https://github.com/openactive/OpenActive.Server.NET/issues/226
protected override async ValueTask BookOrderItems(List<OrderItemContext<SessionOpportunity>> orderItemContexts, StoreBookingFlowContext flowContext, OrderStateContext stateContext, OrderTransaction databaseTransaction)
{
Expand Down Expand Up @@ -581,6 +581,8 @@ protected override async ValueTask BookOrderItems(List<OrderItemContext<SessionO
// Set OrderItemId and access properties for each orderItemContext
ctx.SetOrderItemId(flowContext, bookedOrderItemInfo.OrderItemId);
BookedOrderItemHelper.AddPropertiesToBookedOrderItem(ctx, bookedOrderItemInfo);
// Remove attendee capacity information from the OrderedItem. For more information see: https://github.com/openactive/open-booking-api/issues/156#issuecomment-926643733
BookedOrderItemHelper.RemovePropertiesFromBookedOrderItem(ctx);
}
break;
case ReserveOrderItemsResult.SellerIdMismatch:
Expand Down Expand Up @@ -643,6 +645,8 @@ protected override async ValueTask ProposeOrderItems(List<OrderItemContext<Sessi
foreach (var (ctx, bookedOrderItemInfo) in ctxGroup.Zip(bookedOrderItemInfos, (ctx, bookedOrderItemInfo) => (ctx, bookedOrderItemInfo)))
{
ctx.SetOrderItemId(flowContext, bookedOrderItemInfo.OrderItemId);
// Remove attendee capacity information from the OrderedItem. For more information see: https://github.com/openactive/open-booking-api/issues/156#issuecomment-926643733
BookedOrderItemHelper.RemovePropertiesFromBookedOrderItem(ctx);
}
break;
case ReserveOrderItemsResult.SellerIdMismatch:
Expand Down

0 comments on commit a98b8da

Please sign in to comment.