Hello,
I'm building an application in MVC which allows people to upload and sell there items, (Like ebay but on a much smaller scale)
I currently have a view where they choose the categorie they want to place there item in, when they click ok I pass in the selected values to a view and at this point I need to determin what view to render allowing the user to enter some more information
I currently have a dictionary as follows
public string ReturnView(string categoryId)
{
var views = new Dictionary<string, string>
{
{"Value1", "View1"},
{"Value2", "View2"},
{"Value3", "View3"},
{"Value4", "View4"},
{"Valuen", "Viewn"}
};
string selectedView = views[categoryId];
return selectedView;
}
This returns the view (the above is for testing I havent named my views View1, 2 etc) but each view has a different model associated with it, and im unsure how I can extend this to cater for the model ideally i would like something like this
public string ReturnView(string categoryId)
{
var views = new Dictionary<string, string>
{
{"Value1", "View1", Model1},
{"Value2", "View2", Model2},
{"Value3", "View3", Model3},
{"Value4", "View4", Model4},
{"Valuen", "Viewn", Model5}
};
string selectedView = views[categoryId];
return selectedView;
}
A few people have said use "If" statements but in some categories I have 15 child categories and having a "IF" statement would look quite ugly, And I prefer to do it the proper way.
If someone can help me achieve this I would really appreciate it.