diff --git a/src/EventHub.Application.Contracts/Events/Registrations/IEventRegistrationAppService.cs b/src/EventHub.Application.Contracts/Events/Registrations/IEventRegistrationAppService.cs index d7e8cbe..a5c2b68 100644 --- a/src/EventHub.Application.Contracts/Events/Registrations/IEventRegistrationAppService.cs +++ b/src/EventHub.Application.Contracts/Events/Registrations/IEventRegistrationAppService.cs @@ -16,5 +16,7 @@ namespace EventHub.Events.Registrations Task> GetAttendeesAsync(Guid eventId); Task GetAttendeeCountAsync(Guid eventId); + + Task IsPastEventAsync(Guid eventId); } } diff --git a/src/EventHub.Application/Events/Registrations/EventRegistrationAppService.cs b/src/EventHub.Application/Events/Registrations/EventRegistrationAppService.cs index c04b055..20f296e 100644 --- a/src/EventHub.Application/Events/Registrations/EventRegistrationAppService.cs +++ b/src/EventHub.Application/Events/Registrations/EventRegistrationAppService.cs @@ -85,5 +85,12 @@ namespace EventHub.Events.Registrations { return await _eventRegistrationRepository.CountAsync(x => x.EventId == eventId); } + + public async Task IsPastEventAsync(Guid eventId) + { + var @event = await _eventRepository.GetAsync(eventId); + + return _eventRegistrationManager.IsPastEvent(@event); + } } } diff --git a/src/EventHub.Domain.Shared/Localization/EventHub/en.json b/src/EventHub.Domain.Shared/Localization/EventHub/en.json index ee1e8a0..fa2b05b 100644 --- a/src/EventHub.Domain.Shared/Localization/EventHub/en.json +++ b/src/EventHub.Domain.Shared/Localization/EventHub/en.json @@ -71,7 +71,6 @@ "EventCoverImageExtensionNotAllowed": "This image extension is not allowed. Allowed extensions: png, jpg, jpeg", "ChooseEventCoverImageInfo": "Maximum image size: 1MB.", "ProfilePicturePreview": "Profile Picture Preview", - "EditEvent": "Edit Event", "EventInformation": "Event Information", "EventCapacityLabel": "Capacity (Optional)", "EventCapacityInfo": "Capacity can not be lower than the currently registered user count : {0}", @@ -82,6 +81,7 @@ "EventCoverImage": "Event Cover Image", "EventTimingPreview": "Event Timing Preview", "CoverImagePreview": "Cover Image Preview", - "EventTimingChangeSuccessMessage": "The time of the event has been changed successfully!" + "EventTimingChangeSuccessMessage": "The time of the event has been changed successfully!", + "PastEvent": "Past Event" } } diff --git a/src/EventHub.Domain/Events/Registrations/EventRegistrationManager.cs b/src/EventHub.Domain/Events/Registrations/EventRegistrationManager.cs index 5552d26..6a097f7 100644 --- a/src/EventHub.Domain/Events/Registrations/EventRegistrationManager.cs +++ b/src/EventHub.Domain/Events/Registrations/EventRegistrationManager.cs @@ -20,7 +20,10 @@ namespace EventHub.Events.Registrations Event @event, AppUser user) { - CheckEventEndTime(@event); + if (IsPastEvent(@event)) + { + throw new BusinessException(EventHubErrorCodes.CantRegisterOrUnregisterForAPastEvent); + } if (await IsRegisteredAsync(@event, user)) { @@ -48,7 +51,10 @@ namespace EventHub.Events.Registrations Event @event, AppUser user) { - CheckEventEndTime(@event); + if (IsPastEvent(@event)) + { + throw new BusinessException(EventHubErrorCodes.CantRegisterOrUnregisterForAPastEvent); + } await _eventRegistrationRepository.DeleteAsync( x => x.EventId == @event.Id && x.UserId == user.Id @@ -63,12 +69,14 @@ namespace EventHub.Events.Registrations .AnyAsync(x => x.EventId == @event.Id && x.UserId == user.Id); } - private void CheckEventEndTime(Event @event) + public bool IsPastEvent(Event @event) { if (Clock.Now > @event.EndTime) { - throw new BusinessException(EventHubErrorCodes.CantRegisterOrUnregisterForAPastEvent); + return true; } + + return false; } } } diff --git a/src/EventHub.Web.Theme/Themes/EventHub/Components/Footer/Default.cshtml b/src/EventHub.Web.Theme/Themes/EventHub/Components/Footer/Default.cshtml index 6683925..2cd5616 100644 --- a/src/EventHub.Web.Theme/Themes/EventHub/Components/Footer/Default.cshtml +++ b/src/EventHub.Web.Theme/Themes/EventHub/Components/Footer/Default.cshtml @@ -3,7 +3,7 @@ @using Volo.Abp.Users @inject ICurrentUser CurrentUser -