mirror of https://github.com/abpframework/eventhub
8 changed files with 163 additions and 1 deletions
@ -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; |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace EventHub.Events |
|||
{ |
|||
public class TrackConsts |
|||
{ |
|||
public const int MaxNameLength = 64; |
|||
} |
|||
} |
|||
@ -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<Guid> |
|||
{ |
|||
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<Speaker> 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<Speaker>(); |
|||
} |
|||
|
|||
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; |
|||
} |
|||
} |
|||
} |
|||
@ -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}; |
|||
} |
|||
} |
|||
} |
|||
@ -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<Guid> |
|||
{ |
|||
public Guid EventId { get; private set; } |
|||
|
|||
public string Name { get; private set; } |
|||
|
|||
public ICollection<Session> Sessions { get; private set; } |
|||
|
|||
private Track() |
|||
{ |
|||
|
|||
} |
|||
|
|||
internal Track( |
|||
Guid id, |
|||
Guid eventId, |
|||
string name) |
|||
: base(id) |
|||
{ |
|||
EventId = eventId; |
|||
Name = name; |
|||
Sessions = new Collection<Session>(); |
|||
} |
|||
|
|||
public Track SetName(string name) |
|||
{ |
|||
Name = Check.NotNullOrWhiteSpace(name, nameof(name), TrackConsts.MaxNameLength); |
|||
return this; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue