diff --git a/GetIntoTeachingApi/Services/CrmService.cs b/GetIntoTeachingApi/Services/CrmService.cs index a6f91092b..eafd87b77 100644 --- a/GetIntoTeachingApi/Services/CrmService.cs +++ b/GetIntoTeachingApi/Services/CrmService.cs @@ -41,10 +41,11 @@ public IEnumerable GetCallbackBookingQuotas() { return _service.CreateQuery("dfe_callbackbookingquota", Context()) .Where((entity) => entity.GetAttributeValue("dfe_starttime") > DateTime.UtcNow && - entity.GetAttributeValue("dfe_starttime") < DateTime.UtcNow.AddDays(MaximumCallbackBookingQuotaDaysInAdvance) && - entity.GetAttributeValue("dfe_websitenumberofbookings") < entity.GetAttributeValue("dfe_websitequota")) + entity.GetAttributeValue("dfe_starttime") < DateTime.UtcNow.AddDays(MaximumCallbackBookingQuotaDaysInAdvance)) .OrderBy((entity) => entity.GetAttributeValue("dfe_starttime")) - .Select((entity) => new CallbackBookingQuota(entity, this)); + .Select((entity) => new CallbackBookingQuota(entity, this)) + .ToList() + .Where((quota) => quota.NumberOfBookings < quota.Quota); // Doing this in the Dynamics query throws an exception, though I'm not sure why. } public IEnumerable GetPrivacyPolicies()