Reputation: 454
I'm building a layered WebAPI. I have
Database looks like this:
Courses
- CourseID
Users
- UserID
- FirstName
- LastName
Attendants
- CourseID *
- UserID *
Dates
- CourseID *
- Date
I have made models (Model layer) which are 1:1 fields on database.
Now I want to create a model (business model?) which has:
class Course
List<User> Attendants { get; set; }
List<DateTime> Dates { get; set; }
The goal is to return this model as JSON.
What layer does this model belong in?
Upvotes: 0
Views: 33
Reputation: 218798
The goal is to return this model as JSON
If that's the only goal then it's not a business model, it's a view model. As such, it would belong in the presentation layer.
Business models serve the purpose of defining and structuring the domain logic, independent of any particular technology being used. View models serve the purpose of binding data to a particular technology for presentation.
Ultimately, the question is... To which part of the system should a particular component be coupled? Which other parts of the system will need to rely on it? In this case, it's coupled to a presentation technology and only the presentation layer will rely on it.
Upvotes: 1
Reputation: 4833
I would re-word your layers this way:
Since your Course will be assembled on Control level into view model which will be passed to the view I would suggest to put it into Presentation Layer.
Upvotes: 0