where should the ViewModel creation take place? In the service layer, in the controller?
public class ObjectA {
public string Name {get;set;}
public IList<ChildB> Children {get;set;}
}
public class ObjectAViewModel {
public ObjectA ObjectA {get;set;}
public IList<ChildB> SelectableChildren {get;set;}
}
what if some properties on ObjectA have to be calculated at runtime?
public class ObjectA {
public string Name {get;set;}
public IList<ChildB> Children {get;set;}
public CalculateMethod {get;set;}
public decimal CalculatedValue {get;set;}
}
lets say that ObjectA.CalculatedValue
is calculated out of all or some of the ChildB
objects in the repository (not only the related objects), and that they are calculated differently depending on the CalculateMethod
value? Should i extend the ObjectA
, and in that case, where should i put it? together with ObjectA
or, as a DTO somewhere else? And where should the calculation take place?