I am struggling with how to couple Angular front-ends with Web API back-ends in a way that will allow for abstraction of the domain model /entity framework model for the view and provide a structural standard for developers to follow.
Right now, we publish controllers for entity framework classes. Database first because the database is pre-existing. When forms are posted to the controllers, I have created simple c# classes (view model like) that allow for deserialization of the form/request data to a class object that typically differs slightly from the domain/entity model for example the form may post null for a non-nullable type, or a zero-length string instead of null, etc. This has resulted in a lot code needed to map the “view model” to the domain model. The code in these mappings has resulted in quality issues mostly due to type exceptions. I have even standardized creating typescript interface models directly from the domain models to help enforce some standards in the angular code when validating forms, etc.
Has anyone seen a good example of how others are handling this in the world of model-view-whatever? Coming off of MVC, this seems like a bit of chaos. What am I doing wrong? Is there a known pattern that I’m missing in the Web API /Entity Framework? Else maybe I need to do better at form development to ensure data types are as predictable and compatible with domain models as possible. Any guidance is appreciated.
Thanks, Ali
Aucun commentaire:
Enregistrer un commentaire