I am designing the different layers of a scheduler in c#. This is going to be a service running in the background without a GUI.
This is my baseline for the architecture (ofcourse only being a small snippet of the structure.
I am uncertain about "best-practice" in terms of archeticture. I have been reading about, POCOs, Value Objects, DTOs, Domain Model and from what I can understand, the presented below is a wrong approach to DTOs.
In my class "ScheduleDTP", I have several methods doing some relativ complex manipulations with date coming from the database. CalculatePriority is a simplified example of one of the methods
Database properties: ID, Name, Frequency, LastRun
Manipulated properties: Priority
The purpose of the jobmanager is to evaluate all schedules and on-demands.
To my understanding the DTO should only contain the data, and transfer that between the different layers. I also believe that this should not be the JobManagers resposibility either.
public class ScheduleDTO
{
public Guid ID { get; set; }
public string Name { get; set; }
public int Frequency { get; set; }
public DateTime LastRun { get; set; }
//Calculation based on the values above
public double Priority
{
get
{
return CalculatePriority();
}
}
public double CalculatePriority()
{
return (DateTime.Now - LastRun.AddSeconds(Frequency)).TotalSeconds / 100;
}
}
Should I create some different type of object, POCO, Domail Model, ..., that manipulates the data in the DTOs?
I really appreciate any help about how to construct the different layers or something that that could lead me in the right direction