Skip to content

Commit

Permalink
Merge branch 'master' into feature/bigint-modified
Browse files Browse the repository at this point in the history
  • Loading branch information
civsiv authored Mar 28, 2024
2 parents d7ee40f + e324d68 commit 0610f4d
Show file tree
Hide file tree
Showing 18 changed files with 1,468 additions and 620 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UserSecretsId>aspnet-BookingSystem.AspNetCore-443B4F82-A20C-41CE-9924-329A0BCF0D14</UserSecretsId>
<Configurations>Release;Debug</Configurations>
</PropertyGroup>

<ItemGroup>
Expand All @@ -22,4 +23,5 @@
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>
339 changes: 203 additions & 136 deletions Examples/BookingSystem.AspNetCore/Feeds/FacilitiesFeeds.cs

Large diffs are not rendered by default.

429 changes: 321 additions & 108 deletions Examples/BookingSystem.AspNetCore/Feeds/SessionsFeeds.cs

Large diffs are not rendered by default.

306 changes: 306 additions & 0 deletions Examples/BookingSystem.AspNetCore/Helpers/FeedGenerationHelper.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"profiles": {
"BookingSystem.AspNetCore": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "https://localhost:5001/openactive",
"applicationUrl": "https://localhost:5001",
"environmentVariables": {
Expand Down
64 changes: 62 additions & 2 deletions Examples/BookingSystem.AspNetCore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,68 @@

An example OpenActive.Server.NET implementation.

This implementation is also used as a reference implementation for the [Test Suite](https://github.com/openactive/openactive-test-suite) to run its tests against.
This implementation is also used as a reference implementation for the [Test Suite](https://github.com/openactive/openactive-test-suite) to run its tests against and therefore is often to as Reference Implementation.
Until there are more reference implementations, all references to Reference Implementation refer to this implementation and Reference Implementation and BookingSystem.AspNetCore can be used interchangeably.

## Running Locally
## Running Locally using Visual Studio

In Visual Studio, run the BookingSystem.AspNetCore project

When it's finished building, it will open a page in your browser on port 5001.

Head to `http://localhost:5001/openactive` to check that the project is running correctly. You should see an Open Data landing page.

See the [project contribution documentation](/CONTRIBUTING.md) for details on how to run BookingSystem.AspNetCore locally.

## Running Locally using the CLI

Open a terminal in `Examples/BookingSystem.AspNetCore` directory

Run:

```sh
dotnet run
```

If you want to start BookingSystem.AspNetCore in a specific environment run the following:

```sh
ASPNETCORE_ENVIRONMENT=no-auth dotnet run --no-launch-profile --project ./BookingSystem.AspNetCore.csproj --configuration Release --no-build
```

The above example starts the BookingSystem.AspNetCore in `no-auth` mode.

## BookingSystem.AspNetCore Data Generation

BookingSystem.AspNetCore has three main uses that make it very important in the OpenActive ecosystem:
- For data publishers / booking systems: It is used to demonstrate the properties and shape of data and APIs, according to the OpenActive specifications
- For data users / brokers: It is used as a trial integration where testing can be done with no ramifications
- For contributors: It is used to ensure the Test Suite tests are correct and passing, for different combinations of Open Booking API features.

The data for the sample feeds are generated in two places:
- BookingSystem.AspNetCore/Feeds/*Feeds.cs
- OpenActive.FakeDatabase.NET/Fakes/FakeBookingSystem.cs

The FakeBookingSystem within OpenActive.FakeDatabase.NET acts as the interface to an example database.
The example Feeds within BookingSystem.AspNetCore query this interface and translate the data to conform with the OpenActive Modelling Spec.

Due to this split of functionality, the sample data in the feeds are created/transformed in both files, depending on whether they are important to booking
or not. For example, `Price` is important to booking and there is generated in FakeBookingSystem at startup and stored in the in-memory database. However `Terms Of Service` is not
needed for booking, and therefore is generated at request time.

### Lorem Fitsum mode
When BookingSystem.AspNetCore is run in Lorem Fitsum (a play on [Lorem Ipsum](https://en.wikipedia.org/wiki/Lorem_ipsum)) mode, the data generated contains all the possible fields specified by the OpenActive Modelling Specification.
They are unrealistic representations of data, and the presence of all the fields should not be relied on when developing front-end representations of the data.
However it is very useful for data consumers and deciding on how to present the data to the users.

Lorem Fitsum mode can be running by setting the environment variable `IS_LOREM_FITSUM_MODE` to `true`.
In Visual Studio this can be done in Properties > BookingSystem.AspNetCore Properties > Run > Default > Environment Variables.
In the CLI this can be done by running the following command for example:

```sh
IS_LOREM_FITSUM_MODE=true dotnet run --no-launch-profile --project ./BookingSystem.AspNetCore.csproj --configuration Release --no-build
```

### Golden Records
Golden records are randomly generated records that have maximally enriched properties in the generated data. For example where a record might have one image normally, a golden record will have four.

1 change: 1 addition & 0 deletions Examples/BookingSystem.AspNetCore/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class FeatureSettings
public bool OnlyFreeOpportunities { get; set; } = false;
public bool PrepaymentAlwaysRequired { get; set; } = false;
public bool FacilityUseHasSlots { get; set; } = false;
public bool IsLoremFitsumMode { get; set; } = false;
}

public class PaymentSettings
Expand Down
12 changes: 10 additions & 2 deletions Examples/BookingSystem.AspNetCore/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ public Startup(IConfiguration configuration)
configuration.Bind(AppSettings);

// Provide a simple way to disable token auth for some testing scenarios
if (System.Environment.GetEnvironmentVariable("DISABLE_TOKEN_AUTH") == "true") {
if (System.Environment.GetEnvironmentVariable("DISABLE_TOKEN_AUTH") == "true")
{
AppSettings.FeatureFlags.EnableTokenAuth = false;
}

// Provide a simple way to enable FacilityUseHasSlots for some testing scenarios
if (System.Environment.GetEnvironmentVariable("FACILITY_USE_HAS_SLOTS") == "true") {
if (System.Environment.GetEnvironmentVariable("FACILITY_USE_HAS_SLOTS") == "true")
{
AppSettings.FeatureFlags.FacilityUseHasSlots = true;
}

// Provide a simple way to enable CI mode
if (System.Environment.GetEnvironmentVariable("IS_LOREM_FITSUM_MODE") == "true")
{
AppSettings.FeatureFlags.IsLoremFitsumMode = true;
}
}

public AppSettings AppSettings { get; }
Expand Down
7 changes: 4 additions & 3 deletions Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BookingSystem.AspNetCore.Helpers;
using OpenActive.DatasetSite.NET;
using OpenActive.FakeDatabase.NET;
using OpenActive.NET;
Expand Down Expand Up @@ -320,7 +321,7 @@ protected override async Task GetOrderItems(List<OrderItemContext<FacilityOpport
}),
Name = facility.Name,
Url = new Uri("https://example.com/events/" + slot.FacilityUseId),
Location = _fakeBookingSystem.Database.GetPlaceById(facility.PlaceId),
Location = FeedGenerationHelper.GetPlaceById(facility.PlaceId),
FacilityType = new List<Concept> {
new Concept
{
Expand Down Expand Up @@ -374,11 +375,11 @@ protected override async Task GetOrderItems(List<OrderItemContext<FacilityOpport
// Note this should always be driven from the database, with new FacilityOpportunity's instantiated
Id = RenderOpportunityId(new FacilityOpportunity
{
OpportunityType = _appSettings.FeatureFlags.FacilityUseHasSlots ? OpportunityType.FacilityUseSlot : OpportunityType.IndividualFacilityUseSlot,
OpportunityType = _appSettings.FeatureFlags.FacilityUseHasSlots ? OpportunityType.FacilityUseSlot : OpportunityType.IndividualFacilityUseSlot,
FacilityUseId = slot.FacilityUseId,
SlotId = slot.Id,
IndividualFacilityUseId = !_appSettings.FeatureFlags.FacilityUseHasSlots ? slot.IndividualFacilityUseId : null,
}),
}),
FacilityUse = slotParent,
StartDate = (DateTimeOffset)slot.Start,
EndDate = (DateTimeOffset)slot.End,
Expand Down
4 changes: 2 additions & 2 deletions Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using OpenActive.FakeDatabase.NET;
using RequiredStatusType = OpenActive.FakeDatabase.NET.RequiredStatusType;
using System.Threading.Tasks;

using BookingSystem.AspNetCore.Helpers;

namespace BookingSystem
{
Expand Down Expand Up @@ -361,7 +361,7 @@ protected override async Task GetOrderItems(List<OrderItemContext<SessionOpportu
}),
Name = @class.Title,
Url = new Uri("https://example.com/events/" + occurrence.ClassId),
Location = _fakeBookingSystem.Database.GetPlaceById(@class.PlaceId),
Location = FeedGenerationHelper.GetPlaceById(@class.PlaceId),
Activity = new List<Concept>
{
new Concept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void AddPropertiesToBookedOrderItem(IOrderItemContext ctx, BookedO
new PropertyValue()
{
Name = "Pin Code",
Description = bookedOrderItemInfo.PinCode,
Description = bookedOrderItemInfo.PinCode
}
};
ctx.ResponseOrderItem.AccessPass = new List<ImageObject>
Expand Down
Loading

0 comments on commit 0610f4d

Please sign in to comment.