I am struggling to identify Domain objects.
Problem:
- A company has one or multiple Sites
- A Site has main and multiple contacts
- Thus, a company has one or many contacts. These contacts are allocated to Sites.
- Contacts must be added to Sites not to a company
My Understanding:
public class Company : IEntity
{
public int CompanyId {get;}
public string CompanyName {get;}
//.....
}
public class Site : IEntity
{
public int SiteId {get;}
public string SiteName {get;}
//.....
}
public class Contact : IEntity
{
public int ContactId {get;}
public string SurName {get;}
public bool MainSiteContact {get;}//Confused!! May be this is not the right place
//.....
}
public class SiteContact : IAggregate
{
public Site ASite { get; }
public List<Contact> Contacts { get; }
public Contact MainContact {get;}//Confused!!
//.....
public Contact AddSiteContact(...)
{
}
}
public class CompanySites : IAggregateRoot
{
public Company ACompany { get; }
public List<Site> Sites { get; }
public List<SiteContact> Contacts { get; }
//.....
}
Am i in the right direction? Please correct me if i am wrong...
Update @Beachwalker elaborate the question properly in the comment section below the answer of @Aydin Adn.
@Aydin Adn I think his questions has more than one aspects: 1. How these objects fit correctly in the context of a Domain Driven Design (DDD) aproach and what is their DDD presentation, e.g. AggregateRoot, Entity, ValueObject etc. 2. Is the interpretation of the Domain correct. (Domain Model)
CompanySites
which is a many-to-many relationship, but the way you explain it,Site
just needs aCompanyId
andCompany
needs a set ofSite
. – Silvermind