Перепиливание под чистый DDD

This commit is contained in:
Халимов Рустам
2026-03-22 23:59:33 +03:00
parent 5da1a2f45d
commit 6e532b021d
302 changed files with 3595 additions and 3679 deletions

View File

@@ -0,0 +1,50 @@
using System;
namespace Knot.Modules.Messaging.Domain;
public class TextMessage : Message
{
public override string Type => "text";
public override string? Content { get; protected set; }
public override string? Quote { get; protected set; }
private TextMessage() : base()
{
Content = string.Empty;
}
public TextMessage(
Guid id,
Guid chatId,
Guid senderId,
string content,
Guid? replyToId,
string? quote,
Guid? forwardedFromId,
DateTime createdAt,
bool isImported)
: base(id, chatId, senderId, replyToId, forwardedFromId, createdAt, isImported)
{
Content = content;
Quote = quote;
if (!isImported)
{
RaiseDomainEvent(new MessageSentDomainEvent(Id, ChatId, SenderId, Content));
}
}
public void Edit(string newContent)
{
Content = newContent;
AddState(MessageState.IsEdited);
}
public override void Delete()
{
Content = string.Empty;
base.Delete();
}
}