Razor view to render simple scaffolding for complex type
Having a chain of if...elseif s it is a  good place to start having a registry/resolver container instead.

Please take a look at my answer here.

After refactoring the code and removing the nested if....else s you will have all the logic and actions in one place to look at and you can refactor them in order to be DRY.