1

I am currently refactoring our messy controllers. We have a lot of SelectLists in our controllers. I want a way make it easier to maintain our code base. What would be a good solution a Factory Method, Interface or Base Class? We a lot of these methods floating around our code.

private SelectList getRateContract(IEnumerable items)
    {
        return new SelectList(items, Resources.RSINET.RateContractID, Resources.RSINET.ContractName);
    }

1 Answer 1

1

For a start, if they lie in the controller, these methods should at least be decorated with the NonAction attribute.

The SelectList creation would, in my opinion, be done in the view model, but not everyone uses models in the same way (I know Microsoft don't). You should probably have a call to your model that creates this selectlist. That way, the controller stays in... well, control of the application flow, and the model does its job of containing the data.

Sign up to request clarification or add additional context in comments.

1 Comment

I used a generic typesafe select list to add with my problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.