I’m creating a project from the book Sanderson Pro ASp.net mvc3.
But I have had a problem.
I have a class CreateDiscountViewByUser – a class which describes the creation of discount by the user.
And I do not know where to put it.
In her book, I must put myproject.WebUI. but I want to create a method in myproject.Domain DiscountRepository.
But myprojec.Domain sees myproject.WebUI.
What do I do?
and another big problem mypoject.Domain – a class library. and he does not have the space using System.ComponentModel.DataAnnotations;
I don’t know about the book but…
Your Domain shouldn’t know anything about your View or how the data is rendered. It shouldn’t know anything about how you get data from your repository as well. It’s job is to control the Domain logic by changing state only.
The repositories implementation should be in a different project as well. And then the CreateDiscountViewByUser should be in the UI project because it’s closely related to the view. If you have to put DataAnnotations in the properties of you class then use a DTO for it.
So, my recommendation is:
Domain
Product.ApplyDiscount(Discount))Infrastructure *knows the Domain