Asp.net MVC - ViewModel Design

I have a Create and Edit action on the controller.

I have a viewmodel for every action. Both view modes have approximately 15 properties. 10 are common to both models, and the rest are different.

My question is: should I create some basic model with common properties (preserving DRY) or do I not need it here?

+3
source share
4 answers

This will almost certainly be related to the actual situation you are in. The most important question you ask yourself is this: do these basic properties fulfill some basic object? If so, you are probably safe to have a base class. If not, I would stay away from it and just put the properties on separate models.

, , , , , . , , , .

+4

. , , , , , .:( .

/​​ , , , .

+1

, .

0

, - , , , . .

But assuming there are differences, I would use a base class to share common properties, as elsewhere.

0
source

All Articles