So I've been learning DDD and am attempting to refactor an old project using this approach. It is a fairly small app to register employees for events. These employees are initially populated from the DB, registered, and saved.
One business rule says that if an employee is marked as CannotAttend = true
and they show up, then they are registered normally and CannotAttend
is set to false
.
My question involves the concern of the UI. A message, ReceivedMsg
, is displayed based on the state the object is in when they are registering/attempting to register. The state would be initially set when the object is populated from the DB, and then when they register a different message is displayed based on if they had been marked as CannotAttend
or not. This message is not stored in the DB.
Is this a problem the domain should be concerned about, or should I track these changes elsewhere?
Some example messages are:
Known when populated from DB - Not Currenty Registered
, Already Registered
After registering - Registered
, Registered and set to attend event
The UI displays this message and a color based on the initial state from the DB and then changed once the properties Registered
and/or CannotAttend
have changed.
public class Employee
{
//DB properties
public int EmployeeId { get; private set; }
public string FirstName { get; private set; }
public string LastName { get; private set; }
public int BadgeId { get; private set; }
public bool Registered { get; private set; }
public int Swipes { get; private set; }
public bool CannotAttend { get; private set; }
//Not persisted
public string ReceivedMsg { get; set; }
public RegistrationType RegistrationType { get; private set;}
public void Register(RegistrationType registrationType)
{
if (!Registered)
{
Registered = true;
Swipes = 0;
}
if(CannotAttend)
{
CannotAttend = false;
}
if (registrationType == RegistrationType.Badge) Swipes++;
}
}