jeudi 11 juin 2020

Designing application with generic ViewModel

I am building an application in which a user fills out an application form, this form has 10 parts (I have created 10 database tables for each part). The help I need in is designing the views/viewmodels for each part. 9 out of 10 parts are identical in terms of number of input fields on each view : 9 views would look identical( only the text would change)

I am thinking of creating a generic Viewmodel like :

string MainDescription {get;set;}
int FirstDropdownTId {get;set;}
int FirstDropdownFId {get;set;}
string SecondDescription {get;set}
int SecondDropdownTId {get;set;}
int SecondDropdownFId {get;set;}
string ThirdDescription {get;set}
int ThirdDropdownTId {get;set;}
int ThirdDropdownFId {get;set}

... and so on

and then each view gets it ViewModel which inherits from this generic ViewModel

Questions :

1) Should I create a single view ? I guess this would get complicated if the client decides to make major changes in each part.

2) If the generic ViewModel seems okay, then the naming convention seems odd.

any advice would be much appreciated. I have limited experience with programming, I am using asp.net core for this application.

Thanks

Aucun commentaire:

Enregistrer un commentaire