I'm designing a Web API with the usual CRUD operations on a Person entity.
The problem is that I don't know how to design the DTOs.
The entity is as follows:
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
I have determined that the DTO should have the very same members:
public class PersonDto
{
public int Id { get; set; }
public string Name { get; set; }
public int Age{ get; set; }
}
That makes sense for the Update operation, but what about Create? The Id is create by the Create operation ifself, so having an Id in the DTO doesn't fit the semantics.
Should I create 2 different DTOs, one with Id and another without Id?
What's the best option? Do you have different DTOs for Create and Update?