I am confused about what form data is supposed to be in when passing data from a User Interface in the Presentation Layer to an Application Layer then the Domain Layer for validations. I am passing in a DTO but I've heard I should not. Rather that I should only pass in primitives and scalars to the Domain Layer. I'm not sure how this is done if not using a DTO class structure. Below is how I am using a DTO from my UI:
My User Interface may have values as follows on screen:
Product Name: Product ABC
Product Code: 1234
Description: a description
When the user clicks the submit button to add this record to the database I build a DTO as follows:
public class NewProductDto
{
public string ProductName {get;set;}
public string ProductCode {get;set;}
public string Description {get;set;}
}
I pass this DTO to the Application Layer then to the Domain Layer where it reads the values to validate and create a new instance of an entity.
If I am not supposed to be doing this then how are the values from the UI supposed to be packaged for the Application Layer to receive and send to the Domain Layer to perform validations and creation of new entities?
Maybe just a simple data structure?
struct NewProduct
{
public string ProductName;
public string ProductCode;
public string Description;
}
struct NewProduct aNewProductStructure;
(i.e. CreateNewProduct(aNewProductStructure) instead of CreateNewProduct(aNewProductDto) ?
Thanks in advance.
---------- Update 2/24/2016 9:58 am
Okay based on recent information I overlooked it appears the Application Layer is supposed to receive the DTO from the UI but then converts it into pieces to pass to the domain. So in my example above the Application Layer should pass the new product to be created as follows to the domain layer:
CreateNewProduct(ProductName, ProductCode, Description);
Definition for CreateNewProduct:
public int CreateNewProduct(string ProductName, string ProductCode, string Description)
{
....
}
Basically, I am supposed to pass in the individual values to the Domain.