From a907f258ce108d97d51f0318590482c5771178ac Mon Sep 17 00:00:00 2001 From: nickevansuk <2616208+nickevansuk@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:25:29 +0100 Subject: [PATCH] feat: Fake places and simulation of a custom built system --- .../Feeds/FacilitiesFeeds.cs | 18 +-- .../Feeds/SessionsFeeds.cs | 36 +---- .../Settings/AppSettings.cs | 1 + .../Settings/EngineConfig.cs | 6 +- .../Stores/FacilityStore.cs | 12 +- .../Stores/SessionStore.cs | 2 +- .../appsettings.single-seller.json | 1 + .../Feeds/FacilitiesFeeds.cs | 18 +-- .../Feeds/SessionsFeeds.cs | 36 +---- .../Settings/AppSettings.cs | 1 + .../Settings/EngineConfig.cs | 6 +- .../Stores/FacilityStore.cs | 12 +- .../Stores/SessionStore.cs | 2 +- .../FakeBookingSystem.cs | 139 ++++++++++++++++-- .../Models/ClassTable.cs | 3 +- .../Models/FacilityUseTable.cs | 3 +- 16 files changed, 147 insertions(+), 149 deletions(-) diff --git a/Examples/BookingSystem.AspNetCore/Feeds/FacilitiesFeeds.cs b/Examples/BookingSystem.AspNetCore/Feeds/FacilitiesFeeds.cs index 96d126db..0b2d8301 100644 --- a/Examples/BookingSystem.AspNetCore/Feeds/FacilitiesFeeds.cs +++ b/Examples/BookingSystem.AspNetCore/Feeds/FacilitiesFeeds.cs @@ -88,23 +88,7 @@ protected override async Task>> GetRpdeItems(long? af }, IsOpenBookingAllowed = true, }, - Location = new Place - { - Name = "Fake Pond", - Address = new PostalAddress - { - StreetAddress = "1 Fake Park", - AddressLocality = "Another town", - AddressRegion = "Oxfordshire", - PostalCode = "OX1 1AA", - AddressCountry = "GB" - }, - Geo = new GeoCoordinates - { - Latitude = result.Item1.LocationLat, - Longitude = result.Item1.LocationLng - } - }, + Location = _fakeBookingSystem.Database.GetPlaceById(result.Item1.PlaceId), Url = new Uri("https://www.example.com/a-session-age"), FacilityType = new List { new Concept diff --git a/Examples/BookingSystem.AspNetCore/Feeds/SessionsFeeds.cs b/Examples/BookingSystem.AspNetCore/Feeds/SessionsFeeds.cs index ad0adbad..aba2e7d8 100644 --- a/Examples/BookingSystem.AspNetCore/Feeds/SessionsFeeds.cs +++ b/Examples/BookingSystem.AspNetCore/Feeds/SessionsFeeds.cs @@ -171,40 +171,8 @@ protected override async Task>> GetRpdeItems(long? AllowCustomerCancellationFullRefund = result.Item1.AllowCustomerCancellationFullRefund } }, - Location = result.Item1.AttendanceMode == AttendanceMode.Online ? null : new Place - { - Name = "Fake Pond", - Address = new PostalAddress - { - StreetAddress = "1 Fake Park", - AddressLocality = "Another town", - AddressRegion = "Oxfordshire", - PostalCode = "OX1 1AA", - AddressCountry = "GB" - }, - Geo = new GeoCoordinates - { - Latitude = result.Item1.LocationLat, - Longitude = result.Item1.LocationLng, - } - }, - AffiliatedLocation = result.Item1.AttendanceMode == AttendanceMode.Offline ? null : new Place - { - Name = "Fake Pond", - Address = new PostalAddress - { - StreetAddress = "1 Fake Park", - AddressLocality = "Another town", - AddressRegion = "Oxfordshire", - PostalCode = "OX1 1AA", - AddressCountry = "GB" - }, - Geo = new GeoCoordinates - { - Latitude = result.Item1.LocationLat, - Longitude = result.Item1.LocationLng, - } - }, + Location = result.Item1.AttendanceMode == AttendanceMode.Online ? null : _fakeBookingSystem.Database.GetPlaceById(result.Item1.PlaceId), + AffiliatedLocation = result.Item1.AttendanceMode == AttendanceMode.Offline ? null : _fakeBookingSystem.Database.GetPlaceById(result.Item1.PlaceId), Url = new Uri("https://www.example.com/a-session-age"), Activity = new List { diff --git a/Examples/BookingSystem.AspNetCore/Settings/AppSettings.cs b/Examples/BookingSystem.AspNetCore/Settings/AppSettings.cs index 6ead5201..17fe707a 100644 --- a/Examples/BookingSystem.AspNetCore/Settings/AppSettings.cs +++ b/Examples/BookingSystem.AspNetCore/Settings/AppSettings.cs @@ -15,6 +15,7 @@ public class FeatureSettings { public bool EnableTokenAuth { get; set; } = true; public bool SingleSeller { get; set; } = false; + public bool CustomBuiltSystem { get; set; } = false; public bool PaymentReconciliationDetailValidation { get; set; } = true; public bool OnlyFreeOpportunities { get; set; } = false; public bool PrepaymentAlwaysRequired { get; set; } = false; diff --git a/Examples/BookingSystem.AspNetCore/Settings/EngineConfig.cs b/Examples/BookingSystem.AspNetCore/Settings/EngineConfig.cs index 3d78fc44..09bdeefe 100644 --- a/Examples/BookingSystem.AspNetCore/Settings/EngineConfig.cs +++ b/Examples/BookingSystem.AspNetCore/Settings/EngineConfig.cs @@ -176,9 +176,9 @@ public static StoreBookingEngine CreateStoreBookingEngine(AppSettings appSetting OrganisationPlainTextDescription = "The Reference Implementation provides an example of an full conformant implementation of the OpenActive specifications.", OrganisationLogoUrl = $"{appSettings.ApplicationHostBaseUrl}/images/placeholder-logo.png".ParseUrlOrNull(), OrganisationEmail = "hello@example.com", - PlatformName = "OpenActive Reference Implementation", - PlatformUrl = "https://tutorials.openactive.io/open-booking-sdk/".ParseUrlOrNull(), - PlatformVersion = "1.0", + PlatformName = appSettings.FeatureFlags.CustomBuiltSystem ? null : "OpenActive Reference Implementation", + PlatformUrl = appSettings.FeatureFlags.CustomBuiltSystem ? null : "https://tutorials.openactive.io/open-booking-sdk/".ParseUrlOrNull(), + PlatformVersion = appSettings.FeatureFlags.CustomBuiltSystem ? null : "1.0", BackgroundImageUrl = $"{appSettings.ApplicationHostBaseUrl}/images/placeholder-dataset-site-background.jpg".ParseUrlOrNull(), DateFirstPublished = new DateTimeOffset(new DateTime(2019, 01, 14)), OpenBookingAPIBaseUrl = $"{appSettings.ApplicationHostBaseUrl}/api/openbooking".ParseUrlOrNull(), diff --git a/Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs b/Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs index 0c806d54..7e44b71e 100644 --- a/Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs +++ b/Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs @@ -274,7 +274,7 @@ protected override async Task TriggerTestAction(OpenBookingSimulateAction simula } return; case ChangeOfLogisticsLocationSimulateAction _: - if (!await _fakeBookingSystem.Database.UpdateFacilityUseLocationLatLng(idComponents.SlotId.Value, 0.2m, 0.3m)) + if (!await _fakeBookingSystem.Database.UpdateFacilityUseLocationPlaceId(idComponents.SlotId.Value)) { throw new OpenBookingException(new UnknownOpportunityError()); } @@ -339,15 +339,7 @@ protected override async Task GetOrderItems(List { new Concept { diff --git a/Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs b/Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs index bd767851..42bf975b 100644 --- a/Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs +++ b/Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs @@ -295,7 +295,7 @@ protected override async Task TriggerTestAction(OpenBookingSimulateAction simula } return; case ChangeOfLogisticsLocationSimulateAction _: - if (!await _fakeBookingSystem.Database.UpdateSessionSeriesLocationLatLng(idComponents.ScheduledSessionId.Value, 0.2m, 0.3m)) + if (!await _fakeBookingSystem.Database.UpdateSessionSeriesLocationPlaceId(idComponents.ScheduledSessionId.Value)) { throw new OpenBookingException(new UnknownOpportunityError()); } diff --git a/Examples/BookingSystem.AspNetCore/appsettings.single-seller.json b/Examples/BookingSystem.AspNetCore/appsettings.single-seller.json index c1210ca3..5c4cce23 100644 --- a/Examples/BookingSystem.AspNetCore/appsettings.single-seller.json +++ b/Examples/BookingSystem.AspNetCore/appsettings.single-seller.json @@ -1,6 +1,7 @@ { "FeatureFlags": { "SingleSeller": true, + "CustomBuiltSystem": true, "EnableTokenAuth": false } } diff --git a/Examples/BookingSystem.AspNetFramework/Feeds/FacilitiesFeeds.cs b/Examples/BookingSystem.AspNetFramework/Feeds/FacilitiesFeeds.cs index 96d126db..0b2d8301 100644 --- a/Examples/BookingSystem.AspNetFramework/Feeds/FacilitiesFeeds.cs +++ b/Examples/BookingSystem.AspNetFramework/Feeds/FacilitiesFeeds.cs @@ -88,23 +88,7 @@ protected override async Task>> GetRpdeItems(long? af }, IsOpenBookingAllowed = true, }, - Location = new Place - { - Name = "Fake Pond", - Address = new PostalAddress - { - StreetAddress = "1 Fake Park", - AddressLocality = "Another town", - AddressRegion = "Oxfordshire", - PostalCode = "OX1 1AA", - AddressCountry = "GB" - }, - Geo = new GeoCoordinates - { - Latitude = result.Item1.LocationLat, - Longitude = result.Item1.LocationLng - } - }, + Location = _fakeBookingSystem.Database.GetPlaceById(result.Item1.PlaceId), Url = new Uri("https://www.example.com/a-session-age"), FacilityType = new List { new Concept diff --git a/Examples/BookingSystem.AspNetFramework/Feeds/SessionsFeeds.cs b/Examples/BookingSystem.AspNetFramework/Feeds/SessionsFeeds.cs index ad0adbad..aba2e7d8 100644 --- a/Examples/BookingSystem.AspNetFramework/Feeds/SessionsFeeds.cs +++ b/Examples/BookingSystem.AspNetFramework/Feeds/SessionsFeeds.cs @@ -171,40 +171,8 @@ protected override async Task>> GetRpdeItems(long? AllowCustomerCancellationFullRefund = result.Item1.AllowCustomerCancellationFullRefund } }, - Location = result.Item1.AttendanceMode == AttendanceMode.Online ? null : new Place - { - Name = "Fake Pond", - Address = new PostalAddress - { - StreetAddress = "1 Fake Park", - AddressLocality = "Another town", - AddressRegion = "Oxfordshire", - PostalCode = "OX1 1AA", - AddressCountry = "GB" - }, - Geo = new GeoCoordinates - { - Latitude = result.Item1.LocationLat, - Longitude = result.Item1.LocationLng, - } - }, - AffiliatedLocation = result.Item1.AttendanceMode == AttendanceMode.Offline ? null : new Place - { - Name = "Fake Pond", - Address = new PostalAddress - { - StreetAddress = "1 Fake Park", - AddressLocality = "Another town", - AddressRegion = "Oxfordshire", - PostalCode = "OX1 1AA", - AddressCountry = "GB" - }, - Geo = new GeoCoordinates - { - Latitude = result.Item1.LocationLat, - Longitude = result.Item1.LocationLng, - } - }, + Location = result.Item1.AttendanceMode == AttendanceMode.Online ? null : _fakeBookingSystem.Database.GetPlaceById(result.Item1.PlaceId), + AffiliatedLocation = result.Item1.AttendanceMode == AttendanceMode.Offline ? null : _fakeBookingSystem.Database.GetPlaceById(result.Item1.PlaceId), Url = new Uri("https://www.example.com/a-session-age"), Activity = new List { diff --git a/Examples/BookingSystem.AspNetFramework/Settings/AppSettings.cs b/Examples/BookingSystem.AspNetFramework/Settings/AppSettings.cs index 6ead5201..17fe707a 100644 --- a/Examples/BookingSystem.AspNetFramework/Settings/AppSettings.cs +++ b/Examples/BookingSystem.AspNetFramework/Settings/AppSettings.cs @@ -15,6 +15,7 @@ public class FeatureSettings { public bool EnableTokenAuth { get; set; } = true; public bool SingleSeller { get; set; } = false; + public bool CustomBuiltSystem { get; set; } = false; public bool PaymentReconciliationDetailValidation { get; set; } = true; public bool OnlyFreeOpportunities { get; set; } = false; public bool PrepaymentAlwaysRequired { get; set; } = false; diff --git a/Examples/BookingSystem.AspNetFramework/Settings/EngineConfig.cs b/Examples/BookingSystem.AspNetFramework/Settings/EngineConfig.cs index 3d78fc44..09bdeefe 100644 --- a/Examples/BookingSystem.AspNetFramework/Settings/EngineConfig.cs +++ b/Examples/BookingSystem.AspNetFramework/Settings/EngineConfig.cs @@ -176,9 +176,9 @@ public static StoreBookingEngine CreateStoreBookingEngine(AppSettings appSetting OrganisationPlainTextDescription = "The Reference Implementation provides an example of an full conformant implementation of the OpenActive specifications.", OrganisationLogoUrl = $"{appSettings.ApplicationHostBaseUrl}/images/placeholder-logo.png".ParseUrlOrNull(), OrganisationEmail = "hello@example.com", - PlatformName = "OpenActive Reference Implementation", - PlatformUrl = "https://tutorials.openactive.io/open-booking-sdk/".ParseUrlOrNull(), - PlatformVersion = "1.0", + PlatformName = appSettings.FeatureFlags.CustomBuiltSystem ? null : "OpenActive Reference Implementation", + PlatformUrl = appSettings.FeatureFlags.CustomBuiltSystem ? null : "https://tutorials.openactive.io/open-booking-sdk/".ParseUrlOrNull(), + PlatformVersion = appSettings.FeatureFlags.CustomBuiltSystem ? null : "1.0", BackgroundImageUrl = $"{appSettings.ApplicationHostBaseUrl}/images/placeholder-dataset-site-background.jpg".ParseUrlOrNull(), DateFirstPublished = new DateTimeOffset(new DateTime(2019, 01, 14)), OpenBookingAPIBaseUrl = $"{appSettings.ApplicationHostBaseUrl}/api/openbooking".ParseUrlOrNull(), diff --git a/Examples/BookingSystem.AspNetFramework/Stores/FacilityStore.cs b/Examples/BookingSystem.AspNetFramework/Stores/FacilityStore.cs index 0c806d54..7e44b71e 100644 --- a/Examples/BookingSystem.AspNetFramework/Stores/FacilityStore.cs +++ b/Examples/BookingSystem.AspNetFramework/Stores/FacilityStore.cs @@ -274,7 +274,7 @@ protected override async Task TriggerTestAction(OpenBookingSimulateAction simula } return; case ChangeOfLogisticsLocationSimulateAction _: - if (!await _fakeBookingSystem.Database.UpdateFacilityUseLocationLatLng(idComponents.SlotId.Value, 0.2m, 0.3m)) + if (!await _fakeBookingSystem.Database.UpdateFacilityUseLocationPlaceId(idComponents.SlotId.Value)) { throw new OpenBookingException(new UnknownOpportunityError()); } @@ -339,15 +339,7 @@ protected override async Task GetOrderItems(List { new Concept { diff --git a/Examples/BookingSystem.AspNetFramework/Stores/SessionStore.cs b/Examples/BookingSystem.AspNetFramework/Stores/SessionStore.cs index bd767851..42bf975b 100644 --- a/Examples/BookingSystem.AspNetFramework/Stores/SessionStore.cs +++ b/Examples/BookingSystem.AspNetFramework/Stores/SessionStore.cs @@ -295,7 +295,7 @@ protected override async Task TriggerTestAction(OpenBookingSimulateAction simula } return; case ChangeOfLogisticsLocationSimulateAction _: - if (!await _fakeBookingSystem.Database.UpdateSessionSeriesLocationLatLng(idComponents.ScheduledSessionId.Value, 0.2m, 0.3m)) + if (!await _fakeBookingSystem.Database.UpdateSessionSeriesLocationPlaceId(idComponents.ScheduledSessionId.Value)) { throw new OpenBookingException(new UnknownOpportunityError()); } diff --git a/Fakes/OpenActive.FakeDatabase.NET/FakeBookingSystem.cs b/Fakes/OpenActive.FakeDatabase.NET/FakeBookingSystem.cs index 7d24292e..f2bebf0c 100644 --- a/Fakes/OpenActive.FakeDatabase.NET/FakeBookingSystem.cs +++ b/Fakes/OpenActive.FakeDatabase.NET/FakeBookingSystem.cs @@ -283,7 +283,7 @@ public async Task UpdateFacilitySlotStartAndEndTimeByPeriodInMins(long slo /// /// /// - public async Task UpdateFacilityUseLocationLatLng(long slotId, decimal newLat, decimal newLng) + public async Task UpdateFacilityUseLocationPlaceId(long slotId) { using (var db = await Mem.Database.OpenAsync()) { @@ -295,8 +295,8 @@ public async Task UpdateFacilityUseLocationLatLng(long slotId, decimal new if (facilityUse == null) return false; - facilityUse.LocationLat = newLat; - facilityUse.LocationLng = newLng; + // Round-robin to a different place + facilityUse.PlaceId = (facilityUse.PlaceId + 1) % 3 + 1; facilityUse.Modified = DateTimeOffset.Now.UtcTicks; await db.UpdateAsync(facilityUse); return true; @@ -357,7 +357,7 @@ public async Task UpdateScheduledSessionStartAndEndTimeByPeriodInMins(long /// /// /// - public async Task UpdateSessionSeriesLocationLatLng(long occurrenceId, decimal newLat, decimal newLng) + public async Task UpdateSessionSeriesLocationPlaceId(long occurrenceId) { using (var db = await Mem.Database.OpenAsync()) { @@ -369,8 +369,8 @@ public async Task UpdateSessionSeriesLocationLatLng(long occurrenceId, dec if (classInstance == null) return false; - classInstance.LocationLat = newLat; - classInstance.LocationLng = newLng; + // Round-robin to a different place + classInstance.PlaceId = (classInstance.PlaceId + 1) % 3 + 1; classInstance.Modified = DateTimeOffset.Now.UtcTicks; await db.UpdateAsync(classInstance); return true; @@ -638,6 +638,118 @@ await db.InsertAsync(new OrderTable } } + public OpenActive.NET.Place GetPlaceById(long placeId) + { + // Three hardcoded fake places + switch (placeId) + { + case 1: + return new OpenActive.NET.Place + { + Identifier = 1, + Name = "Post-ercise Plaza", + Description = "Sorting Out Your Fitness One Parcel Lift at a Time! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + Address = new OpenActive.NET.PostalAddress + { + StreetAddress = "Kings Mead House", + AddressLocality = "Oxford", + AddressRegion = "Oxfordshire", + PostalCode = "OX1 1AA", + AddressCountry = "GB" + }, + Geo = new OpenActive.NET.GeoCoordinates + { + Latitude = (decimal?)51.7502, + Longitude = (decimal?)-1.2674 + }, + Image = new List { + new OpenActive.NET.ImageObject + { + Url = new Uri("https://upload.wikimedia.org/wikipedia/commons/e/e5/Oxford_StAldates_PostOffice.jpg") + }, + }, + Telephone = "01865 000001", + Url = new Uri("https://en.wikipedia.org/wiki/Post_Office_Limited"), + AmenityFeature = new List + { + new OpenActive.NET.ChangingFacilities { Name = "Changing Facilities", Value = true }, + new OpenActive.NET.Showers { Name = "Showers", Value = true }, + new OpenActive.NET.Lockers { Name = "Lockers", Value = true }, + new OpenActive.NET.Towels { Name = "Towels", Value = false }, + new OpenActive.NET.Creche { Name = "Creche", Value = false }, + new OpenActive.NET.Parking { Name = "Parking", Value = false } + } + }; + case 2: + return new OpenActive.NET.Place + { + Identifier = 2, + Name = "Premier Lifters", + Description = "Where your Fitness Goals are Always Inn-Sight. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + Address = new OpenActive.NET.PostalAddress + { + StreetAddress = "Greyfriars Court, Paradise Square", + AddressLocality = "Oxford", + AddressRegion = "Oxfordshire", + PostalCode = "OX1 1BB", + AddressCountry = "GB" + }, + Geo = new OpenActive.NET.GeoCoordinates + { + Latitude = (decimal?)51.7504933, + Longitude = (decimal?)-1.2620685 + }, + Image = new List { + new OpenActive.NET.ImageObject + { + Url = new Uri("https://upload.wikimedia.org/wikipedia/commons/5/53/Cambridge_Orchard_Park_Premier_Inn.jpg") + }, + }, + Telephone = "01865 000002", + Url = new Uri("https://en.wikipedia.org/wiki/Premier_Inn"), + AmenityFeature = new List + { + new OpenActive.NET.ChangingFacilities { Name = "Changing Facilities", Value = false }, + new OpenActive.NET.Showers { Name = "Showers", Value = false }, + new OpenActive.NET.Lockers { Name = "Lockers", Value = false }, + new OpenActive.NET.Towels { Name = "Towels", Value = true }, + new OpenActive.NET.Creche { Name = "Creche", Value = true }, + new OpenActive.NET.Parking { Name = "Parking", Value = true } + } + }; + case 3: + return new OpenActive.NET.Place + { + Identifier = 3, + Name = "Stroll & Stretch", + Description = "Casual Calisthenics in the Heart of Commerce. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + Address = new OpenActive.NET.PostalAddress + { + StreetAddress = "Norfolk Street", + AddressLocality = "Oxford", + AddressRegion = "Oxfordshire", + PostalCode = "OX1 1UU", + AddressCountry = "GB" + }, + Geo = new OpenActive.NET.GeoCoordinates + { + Latitude = (decimal?)51.749826, + Longitude = (decimal?)-1.261492 + }, + Image = new List { + new OpenActive.NET.ImageObject + { + Url = new Uri("https://upload.wikimedia.org/wikipedia/commons/2/28/Westfield_Garden_State_Plaza_-_panoramio.jpg") + }, + }, + Telephone = "01865 000003", + Url = new Uri("https://en.wikipedia.org/wiki/Shopping_center"), + }; + default: + return null; + } + } + public async Task<(bool, FacilityUseTable, SlotTable, BookedOrderItemInfo)> GetSlotAndBookedOrderItemInfoBySlotId(Guid uuid, long? slotId) { using (var db = await Mem.Database.OpenAsync()) @@ -1381,7 +1493,8 @@ private static async Task CreateFakeFacilitiesAndSlots(IDbConnection db) Id = seed.Id, Deleted = false, Name = $"{Faker.Commerce.ProductMaterial()} {Faker.PickRandomParam("Sports Hall", "Swimming Pool Hall", "Running Hall", "Jumping Hall")}", - SellerId = Faker.Random.Bool(0.8f) ? Faker.Random.Long(1, 2) : Faker.Random.Long(3, 5), // distribution: 80% 1-2, 20% 3-5 + SellerId = Faker.Random.Bool(0.8f) ? Faker.Random.Long(1, 2) : Faker.Random.Long(3, 5), // distribution: 80% 1-2, 20% 3-5 + PlaceId = Faker.PickRandom(new[] { 1, 2, 3 }) }) .AsList(); @@ -1459,7 +1572,8 @@ public static async Task CreateFakeClasses(IDbConnection db) SellerId = Faker.Random.Bool(0.8f) ? Faker.Random.Long(1, 2) : Faker.Random.Long(3, 5), // distribution: 80% 1-2, 20% 3-5 ValidFromBeforeStartDate = @class.ValidFromBeforeStartDate, AttendanceMode = Faker.PickRandom(), - AllowCustomerCancellationFullRefund = Faker.Random.Bool() + AllowCustomerCancellationFullRefund = Faker.Random.Bool(), + PlaceId = Faker.PickRandom(new[] { 1, 2, 3 }) }; }) .AsList(); @@ -1743,8 +1857,6 @@ public async Task RemoveAllGrants(string subjectId, string sessionId, string cli RequiredStatusType? prepayment = null, bool requiresAttendeeValidation = false, bool requiresAdditionalDetails = false, - decimal locationLat = 0.1m, - decimal locationLng = 0.1m, bool isOnlineOrMixedAttendanceMode = false, bool allowProposalAmendment = false, bool inPast = false) @@ -1775,8 +1887,7 @@ public async Task RemoveAllGrants(string subjectId, string sessionId, string cli RequiresAdditionalDetails = requiresAdditionalDetails, RequiredAdditionalDetails = requiresAdditionalDetails ? PickRandomAdditionalDetails() : null, AllowsProposalAmendment = allowProposalAmendment, - LocationLat = locationLat, - LocationLng = locationLng, + PlaceId = Faker.PickRandom(new[] { 1, 2, 3 }), AttendanceMode = isOnlineOrMixedAttendanceMode ? Faker.PickRandom(new[] { AttendanceMode.Mixed, AttendanceMode.Online }) : AttendanceMode.Offline, AllowCustomerCancellationFullRefund = allowCustomerCancellationFullRefund, Modified = DateTimeOffset.Now.UtcTicks @@ -1815,7 +1926,6 @@ public async Task RemoveAllGrants(string subjectId, string sessionId, string cli RequiredStatusType? prepayment = null, bool requiresAttendeeValidation = false, bool requiresAdditionalDetails = false, - decimal locationLat = 0.1m, decimal locationLng = 0.1m, bool allowProposalAmendment = false, bool inPast = false) @@ -1832,8 +1942,7 @@ public async Task RemoveAllGrants(string subjectId, string sessionId, string cli Deleted = false, Name = title, SellerId = sellerId ?? 1, - LocationLat = locationLat, - LocationLng = locationLng, + PlaceId = Faker.PickRandom(new[] { 1, 2, 3 }), Modified = DateTimeOffset.Now.UtcTicks }; await db.SaveAsync(facility); diff --git a/Fakes/OpenActive.FakeDatabase.NET/Models/ClassTable.cs b/Fakes/OpenActive.FakeDatabase.NET/Models/ClassTable.cs index daac55f9..2395bc7b 100644 --- a/Fakes/OpenActive.FakeDatabase.NET/Models/ClassTable.cs +++ b/Fakes/OpenActive.FakeDatabase.NET/Models/ClassTable.cs @@ -21,8 +21,7 @@ public class ClassTable : Table public bool RequiresApproval { get; set; } public TimeSpan? ValidFromBeforeStartDate { get; set; } public TimeSpan? LatestCancellationBeforeStartDate { get; set; } - public decimal LocationLat { get; set; } - public decimal LocationLng { get; set; } + public long PlaceId { get; set; } public AttendanceMode AttendanceMode { get; set; } public bool AllowsProposalAmendment { get; set; } } diff --git a/Fakes/OpenActive.FakeDatabase.NET/Models/FacilityUseTable.cs b/Fakes/OpenActive.FakeDatabase.NET/Models/FacilityUseTable.cs index c875db32..6e1f986e 100644 --- a/Fakes/OpenActive.FakeDatabase.NET/Models/FacilityUseTable.cs +++ b/Fakes/OpenActive.FakeDatabase.NET/Models/FacilityUseTable.cs @@ -11,7 +11,6 @@ public class FacilityUseTable : Table public SellerTable SellerTable { get; set; } [ForeignKey(typeof(SellerTable), OnDelete = "CASCADE")] public long SellerId { get; set; } // Provider - public decimal LocationLat { get; set; } - public decimal LocationLng { get; set; } + public long PlaceId { get; set; } } } \ No newline at end of file