I have two screens, a standard user screen and an admin screen. The changes between the two are fairly minor – a few extra buttons and options on the admin screen.
As far as MVC best practices, is it better to:
-
Use the same view and the same viewmodel for both the admin and the standard user screen. That way there is no code duplication, but I will have several if…else statements in the view and controller
-
Use separate views and viewmodels for the admin and user screens. This leads to some code duplication, but is ultimately the most flexible if the screens end up diverging more than they currently are.
-
Some other great solution for this?
I would use seperate viewmodels and apply inheritance to your
ViewModel.So you are not duplicating the code.I personally prefer to keep separate views because it makes things clean and more readable /maintainable. Now you have 2 separate ViewModels, so have separate views. You may consider render Partial Views (in both the views) as necessary