jeudi 12 septembre 2019

Reusing Repository Model in Service Model?

I am implementing a Web Api and am currently separating the Services Model from the Domain Model. But I am wondering if it is bad practice to reuse Repository Model in the Controller Model?

For example:

Repository Models

PersonRepositoryModel {
    public string Name { get; set; }
}

PersonAddressRepositoryModel {
    public string StreetName { get; set; }
}

Service Model

PersonServiceModel {
    public string Name { get; set; }
    public List<PersonAddressRepositoryModel> { get; set; } // <-- Is this bad? Should I create a PersonAddressServiceModel?

}

My question is, is it always good practice to create Service Models even though the properties are exactly the same? Example is usage of PersonAddressRepositoryModel above where it will not have any different properties.

And then I would need to create an instance of the RepositoryModel if I want to use it in my repository like so:

IPersonRepository {
   public long AddNewPersonAddress(PersonAddressRepositoryModel newAddress);
}

Aucun commentaire:

Enregistrer un commentaire