Say I have the following code made in notepad, so sorry any minor bugs :)
My problem is that in order to return any errors with no ModelState, I need to create a viewmodel model again so that I can create any elements on the page that use these objects (genres, artists, etc.). The problem is that it requires me to copy and paste some code from ActionResult to ActionResult, which apparently makes my code not very dry.
Is there a better way to avoid repeated code? At the moment, I just moved the generation of any default objects that are required in the viewmodel to a separate method and / or constructor, but this is a bit messy, since I have to generate all the objects that may be needed for the entire controller. What I was hoping I could do was to point my second index action to the first index action and just use it as a regular method. I tried several different ways to do this, although I cannot return an ActionResult to another ActionResult.
Any thoughts?
source share