From d5ff02833517d311b395e76cdbb0e71783740c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 17 Jul 2021 12:57:19 +0300 Subject: [PATCH] Introduced tracks, sesions and speakers. --- .../EventHubErrorCodes.cs | 1 + .../Events/SessionConsts.cs | 14 ++++ .../Events/TrackConsts.cs | 7 ++ .../Localization/EventHub/en.json | 3 +- src/EventHub.Domain/Events/Event.cs | 7 ++ src/EventHub.Domain/Events/Session.cs | 70 +++++++++++++++++++ src/EventHub.Domain/Events/Speaker.cs | 23 ++++++ src/EventHub.Domain/Events/Track.cs | 39 +++++++++++ 8 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 src/EventHub.Domain.Shared/Events/SessionConsts.cs create mode 100644 src/EventHub.Domain.Shared/Events/TrackConsts.cs create mode 100644 src/EventHub.Domain/Events/Session.cs create mode 100644 src/EventHub.Domain/Events/Speaker.cs create mode 100644 src/EventHub.Domain/Events/Track.cs diff --git a/src/EventHub.Domain.Shared/EventHubErrorCodes.cs b/src/EventHub.Domain.Shared/EventHubErrorCodes.cs index 4b4bccd..c92a112 100644 --- a/src/EventHub.Domain.Shared/EventHubErrorCodes.cs +++ b/src/EventHub.Domain.Shared/EventHubErrorCodes.cs @@ -5,6 +5,7 @@ public const string OrganizationNameAlreadyExists = "EventHub:OrganizationNameAlreadyExists"; public const string NotAuthorizedToCreateEventInThisOrganization = "EventHub:NotAuthorizedToCreateEventInThisOrganization"; public const string EventEndTimeCantBeEarlierThanStartTime = "EventHub:EventEndTimeCantBeEarlierThanStartTime"; + public const string SessionEndTimeCantBeEarlierThanStartTime = "EventHub:SessionEndTimeCantBeEarlierThanStartTime"; public const string CantRegisterOrUnregisterForAPastEvent = "EventHub:CantRegisterOrUnregisterForAPastEvent"; public const string NotAuthorizedToUpdateOrganizationProfile = "EventHub:NotAuthorizedToUpdateOrganizationProfile"; public const string CapacityOfEventFull = "EventHub:CapacityOfEventFull"; diff --git a/src/EventHub.Domain.Shared/Events/SessionConsts.cs b/src/EventHub.Domain.Shared/Events/SessionConsts.cs new file mode 100644 index 0000000..8f7e304 --- /dev/null +++ b/src/EventHub.Domain.Shared/Events/SessionConsts.cs @@ -0,0 +1,14 @@ +namespace EventHub.Events +{ + public class SessionConsts + { + public const int MinTitleLength = 8; + public const int MaxTitleLength = 128; + + public const int MinDescriptionLength = 50; + public const int MaxDescriptionLength = 2000; + + public const int MinLanguageLength = 2; + public const int MaxLanguageLength = 16; + } +} \ No newline at end of file diff --git a/src/EventHub.Domain.Shared/Events/TrackConsts.cs b/src/EventHub.Domain.Shared/Events/TrackConsts.cs new file mode 100644 index 0000000..71b1de5 --- /dev/null +++ b/src/EventHub.Domain.Shared/Events/TrackConsts.cs @@ -0,0 +1,7 @@ +namespace EventHub.Events +{ + public class TrackConsts + { + public const int MaxNameLength = 64; + } +} \ No newline at end of file diff --git a/src/EventHub.Domain.Shared/Localization/EventHub/en.json b/src/EventHub.Domain.Shared/Localization/EventHub/en.json index fa2b05b..0aca53c 100644 --- a/src/EventHub.Domain.Shared/Localization/EventHub/en.json +++ b/src/EventHub.Domain.Shared/Localization/EventHub/en.json @@ -82,6 +82,7 @@ "EventTimingPreview": "Event Timing Preview", "CoverImagePreview": "Cover Image Preview", "EventTimingChangeSuccessMessage": "The time of the event has been changed successfully!", - "PastEvent": "Past Event" + "PastEvent": "Past Event", + "EventHub:SessionEndTimeCantBeEarlierThanStartTime": "Session end time can not be earlier than the start time." } } diff --git a/src/EventHub.Domain/Events/Event.cs b/src/EventHub.Domain/Events/Event.cs index eb6a386..6011a69 100644 --- a/src/EventHub.Domain/Events/Event.cs +++ b/src/EventHub.Domain/Events/Event.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; @@ -41,6 +43,8 @@ namespace EventHub.Events public int TimingChangeCount { get; set; } public bool IsTimingChangeEmailSent { get; set; } + + public ICollection Tracks { get; private set; } private Event() { @@ -59,9 +63,12 @@ namespace EventHub.Events { OrganizationId = organizationId; UrlCode = Check.NotNullOrWhiteSpace(urlCode, urlCode, EventConsts.UrlCodeLength, EventConsts.UrlCodeLength); + SetTitle(title); SetDescription(description); SetTimeInternal(startTime, endTime); + + Tracks = new Collection(); } public Event SetTitle(string title) diff --git a/src/EventHub.Domain/Events/Session.cs b/src/EventHub.Domain/Events/Session.cs new file mode 100644 index 0000000..2b6f539 --- /dev/null +++ b/src/EventHub.Domain/Events/Session.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Volo.Abp; +using Volo.Abp.Domain.Entities; + +namespace EventHub.Events +{ + public class Session : Entity + { + public Guid TrackId { get; private set; } + + public string Title { get; private set; } + + public DateTime StartTime { get; private set; } + + public DateTime EndTime { get; private set; } + + public string Description { get; private set; } + + public string Language { get; set; } + + public ICollection Speakers { get; private set; } + + private Session() + { + + } + + internal Session( + Guid id, + Guid trackId, + string title, + DateTime startTime, + DateTime endTime, + string description) + : base(id) + { + TrackId = trackId; + SetTitle(title); + SetDescription(description); + SetTime(startTime, endTime); + Speakers = new Collection(); + } + + public Session SetTitle(string title) + { + Title = Check.NotNullOrWhiteSpace(title, nameof(title), SessionConsts.MaxTitleLength, SessionConsts.MinTitleLength); + return this; + } + + public Session SetDescription(string description) + { + Description = Check.NotNullOrWhiteSpace(description, nameof(description), SessionConsts.MaxDescriptionLength, SessionConsts.MinDescriptionLength); + return this; + } + + internal Session SetTime(DateTime startTime, DateTime endTime) + { + if (startTime > endTime) + { + throw new BusinessException(EventHubErrorCodes.SessionEndTimeCantBeEarlierThanStartTime); + } + + StartTime = startTime; + EndTime = endTime; + return this; + } + } +} \ No newline at end of file diff --git a/src/EventHub.Domain/Events/Speaker.cs b/src/EventHub.Domain/Events/Speaker.cs new file mode 100644 index 0000000..f978562 --- /dev/null +++ b/src/EventHub.Domain/Events/Speaker.cs @@ -0,0 +1,23 @@ +using System; +using Volo.Abp.Domain.Entities; + +namespace EventHub.Events +{ + public class Speaker : Entity + { + public Guid SessionId { get; private set; } + + public Guid UserId { get; private set; } + + public Speaker(Guid sessionId, Guid userId) + { + SessionId = sessionId; + UserId = userId; + } + + public override object[] GetKeys() + { + return new object[] {SessionId, UserId}; + } + } +} \ No newline at end of file diff --git a/src/EventHub.Domain/Events/Track.cs b/src/EventHub.Domain/Events/Track.cs new file mode 100644 index 0000000..908308f --- /dev/null +++ b/src/EventHub.Domain/Events/Track.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Volo.Abp; +using Volo.Abp.Domain.Entities; + +namespace EventHub.Events +{ + public class Track : Entity + { + public Guid EventId { get; private set; } + + public string Name { get; private set; } + + public ICollection Sessions { get; private set; } + + private Track() + { + + } + + internal Track( + Guid id, + Guid eventId, + string name) + : base(id) + { + EventId = eventId; + Name = name; + Sessions = new Collection(); + } + + public Track SetName(string name) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), TrackConsts.MaxNameLength); + return this; + } + } +} \ No newline at end of file