Suppose I am working on a Car Portal. To search a new car, the user provides the following information:
- Brand
- Model
- ModelVersion
- FuelType
- Budget
Business Rules:
- If user selects Brand only : Show brand list page with all models of selected brand
- If user selects Brand and Model : Show Model List page
- If user selects Brand + Model + Model version : Show model version details page.
- if user selects Fuel type OR Budget : Show Brand list page.
Now I have two approaches to define controller and action.
Approach 1: One Controller class with multiple action method
Controller Class : CarSearchmanager
with following are Action Methods:
- SearchNewCar(int Barnd,int Model.......)
Depending on user selection this method will redirect control to following
action method:
- BrandListing(int BrandID......)
- ModelListing(int BrandID,intModelID.....)
- ModelVersionDetails((int BrandID,intModelID,int ModelVersionID....)
Approach 2: Multiple controller class
Controller Class : CarSearchmanager
Following are Action Methods:
- SearchNewCar(int Barnd,int Model.......)
Depending on user selection this method will redirect control to following
controller action method:
Then I will have separate controller class and action method for each of the pages like
bellow:
- BrandListing
- ModelListing
- ModelVersionDetails
I am very confused about how to organize the controller class and action methods. Is there any best practice kind of document? Please suggest one to me.