Browse Source

Implement Max capacity logic on registration

pull/20/head
Berkan 6 years ago
parent
commit
ed2cd4f1c1
  1. 1
      src/EventHub.Domain.Shared/EventHubErrorCodes.cs
  2. 3
      src/EventHub.Domain.Shared/Localization/EventHub/en.json
  3. 8
      src/EventHub.Domain/Events/Registrations/EventRegistrationManager.cs

1
src/EventHub.Domain.Shared/EventHubErrorCodes.cs

@ -7,5 +7,6 @@
public const string EventEndTimeCantBeEarlierThanStartTime = "EventHub:EventEndTimeCantBeEarlierThanStartTime";
public const string CantRegisterOrUnregisterForAPastEvent = "EventHub:CantRegisterOrUnregisterForAPastEvent";
public const string NotAuthorizedToUpdateOrganizationProfile = "EventHub:NotAuthorizedToUpdateOrganizationProfile";
public const string CapacityOfEventFull = "EventHub:CapacityOfEventFull";
}
}

3
src/EventHub.Domain.Shared/Localization/EventHub/en.json

@ -47,6 +47,7 @@
"EditOrganization": "Edit Organization",
"PersonalWebsite": "Personal Website",
"SocialMedia": "Social Media",
"EventHub:NotAuthorizedToUpdateOrganizationProfile": "You are not authorized to update the \"{OrganizationName}\" organization."
"EventHub:NotAuthorizedToUpdateOrganizationProfile": "You are not authorized to update the \"{OrganizationName}\" organization.",
"EventHub:CapacityOfEventFull": "\"{EventTitle}\" event capacity is full!"
}
}

8
src/EventHub.Domain/Events/Registrations/EventRegistrationManager.cs

@ -27,7 +27,15 @@ namespace EventHub.Events.Registrations
{
return;
}
var registrationCount = await _eventRegistrationRepository.CountAsync(x => x.EventId == @event.Id);
if (@event.Capacity != null && registrationCount >= @event.Capacity)
{
throw new BusinessException(EventHubErrorCodes.CapacityOfEventFull)
.WithData("EventTitle", @event.Title);
}
await _eventRegistrationRepository.InsertAsync(
new EventRegistration(
GuidGenerator.Create(),

Loading…
Cancel
Save