Yea but it ain’t gonna be pretty.
I just posted another question where I went ahead and described my domain. I’ll give a brief description of the AR and then the process of what I’m doing here.
Basically and Email system
Converstaion -AR
– properites
– ConversationSender
– ConversationRecipient
– Message
– -- properties
– -- MessageSender
– -- MessageRecipient
public class Conversation : AggregateBase
{
public Conversation(CreateConversationCommand command)
{
Subject = command.Subject;
ConversationTypeCode = ConversationTypeCode.Inquiry;
RaiseEvent(new ConversationCreatedEvent(command.Subject, ConversationTypeCode));
AddConversationSender(command.CreateConversationBrideCommand);
AddConversationRecipient(command.CreateConversationProfileCommand);
AddInitialMessage(command.CreateInitialMessageCommand);
}
private void AddConversationSender(CreateConversationBrideCommand command)
{
if (_conversationParticipants.Any(x => x.ParticipantCode == ParticipantCode.From))
{
throw new Exception(“A Conversation can only have one Sender”);
}
var conversationBride = new ConversationBride(command);
_conversationParticipants.Add(conversationBride);
RaiseEvent(new ConversationSenderBrideCreatedEvent(conversationBride.City,
ConversationStateCode.Sent,
ConversationTypeStatusCode.New,
conversationBride.DisplayName,
conversationBride.Email,
conversationBride.EventBudget,
conversationBride.EventDate,
conversationBride.ExpectedGuestsMin,
conversationBride.FirstName,
conversationBride.LastName,
conversationBride.MemberId,
ParticipantCode.From,
ParticipantTypeCode.Bride,
conversationBride.Phone));
}
private void Apply(ConversationCreatedEvent vent)
{
Subject = vent.Subject;
ConversationTypeCode = Enumeration.FromValue(vent.ConversationType);
}
private void Appy(ConversationSenderBrideCreatedEvent vent)
{
_conversationParticipants.Add(new ConversationBride
{
City = vent.City,
ConversationStateCode = Enumeration.FromValue(vent.ConversationStateCode),
ConversationTypeStatusCode = Enumeration.FromValue(vent.ConversationTypeStatusCode),
DisplayName = vent.FirstName + " " + vent.LastName,
Email = vent.Email,
EventBudget = vent.EventBudget,
EventDate = vent.EventDate,
ExpectedGuestsMax = vent.Guests,
ExpectedGuestsMin = vent.Guests,
FirstName = vent.FirstName,
LastName = vent.LastName,
MemberId = vent.MemberId,
ParticipantCode = Enumeration.FromValue(vent.ParticipantCode),
ParticipantTypeCode = Enumeration.FromValue(vent.ParticipantTypeCode),
Phone = vent.Phone
});
}
Then in ConversationBride I have
public class ConversationBride : ConversationParticipant
{
public ConversationBride(){}
public ConversationBride(CreateConversationBrideCommand command)
{
City = command.City;
ConversationStateCode = ConversationStateCode.Sent;
ConversationTypeStatusCode = ConversationTypeStatusCode.New;
DisplayName = command.FirstName + " " + command.LastName;
Email = command.Email;
EventBudget = command.WeddingBudget;
EventDate = command.EventDate;
ExpectedGuestsMax = command.ExpectedGuests;
ExpectedGuestsMin = command.ExpectedGuests;
FirstName = command.FirstName;
LastName = command.LastName;
MemberId = command.MemberId;
ParticipantCode = ParticipantCode.From;
ParticipantTypeCode = ParticipantTypeCode.Bride;
Phone = command.PhoneNumber;
}
public virtual string MemberId { get; set; }
public virtual string Phone { get; set; }
public virtual string City { get; set; }
public virtual State State { get; set; }
public virtual DateTime? EventDate { get; set; }
public virtual int ExpectedGuestsMin { get; set; }
public virtual int ExpectedGuestsMax { get; set; }
public virtual long EventBudget { get; set; }
}
Now as I said this is an initial spike derived from the code we currently have. I know there are problems and that’s kind of why i’m posting this
For one I either have to have a paramerterless constructor and a bunch of get;set; s or perhaps I should have constructor that takes all the properties, and then not use the command. but that just introduces even more repetition.
Thanks for your thoughts.
R