34 lines
944 B
C#
34 lines
944 B
C#
using Femto.Common.Domain;
|
|
using Femto.Modules.Blog.Domain.Posts.Events;
|
|
using Femto.Modules.Blog.Emoji;
|
|
|
|
namespace Femto.Modules.Blog.Domain.Posts;
|
|
|
|
internal class Post : Entity
|
|
{
|
|
public Guid Id { get; private set; }
|
|
public Guid AuthorId { get; private set; }
|
|
public string Content { get; private set; } = null!;
|
|
public IList<PostMedia> Media { get; private set; }
|
|
|
|
public IList<PostReaction> Reactions { get; private set; } = [];
|
|
public bool IsPublic { get; set; }
|
|
|
|
private Post() { }
|
|
|
|
public Post(Guid authorId, string content, IList<PostMedia> media)
|
|
{
|
|
this.Id = Guid.CreateVersion7();
|
|
this.AuthorId = authorId;
|
|
this.Content = content;
|
|
this.Media = media;
|
|
|
|
this.Reactions = AllEmoji
|
|
.GetRandomEmoji(5)
|
|
.Select(emoji => new PostReaction(emoji, 0))
|
|
.ToList();
|
|
|
|
this.AddDomainEvent(new PostCreated(this));
|
|
}
|
|
|
|
}
|