The first place where such information can be presented is the database ... or any "virtual store" such as a web service that offers you the db interface. In fact, if there are other db units that use these values, they MUST be represented in the database, otherwise you will run into big problems. Actually, suppose one of these values is a row .... if you do not define a table containing all possible values + a key and just write a row, as in other tables ... it will be impossible for you to change the format of the row, since it will “spread” throughout your db ... On the contrary, if you just use a foreign key to refer to such strings ... you can easily change them, since the string is stored only in one place in your dB. Also, in the solution of the enumeration, the problem arises that you cannot add or delete values ... therefore, if such operations "conceptually" can make sense, you cannot use the enumeration. You can use the enumeration when all options “conceptually cover” all the possibilities, so you are sure that you will never add / remove other parameters, for example, in the case of an enumeration (yes, no, it is unknown).
However, after you have your options in db, it’s easy ... you will have DTO objects or business entities representing them in exactly the same way as for all other DB entities.
For visualization purposes, you may have a ViewModel version for these parameters, which can contain only the key and description, as well as the "Repository" method, which your controllers can call to have a list of all parameters.
After you have extracted, the controllers put them in a shared ViewViewModel page ... along with all the other information that will be displayed on the page. From the ViewModel ... you can access them to put them in a drop-down list.
To summarize: 1) You need a DB presentation of your options 2) Then you will have a DTO, a business layer and a View version of these entities ... as needed, exactly the same as for all other DB entities.
source share