AR Create instance for AR
EDGAR CORRÃA <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
Hi guys
My situation is following: I have a AR named as Task, it's has a method DispatchFor(Area area). The problem is that when this method is called, it change object state and create new Task object to area sent with parameter.
What do you think? Where is missing? I keep it? or take this logic to a Domain Service?
public class Task : AggregateRoot
{
public void State State {get; protected set;}
public void TaskType Type {get; protected set;}
public void Area area { get; protected set;}
public Task(TaskType type, Area area)
{
Type = type;
Area = area;
State = State.Pending;
}
public Task DispatchFor(Area area)
{
State = State.Performed;
if (area.IsDirectorShip)
return new Task(TaskType.Analyze, area);
if (area.IsManagement)
return new Task(TaskType.Providence, area);
return new Task(TaskType.File, area);
}
}
------------------------------------