Ok this is something I like to discuss. We have routes like:
.../browse
.../brand/audi/a4
.../category/tail-lights-17
.../search?t=fog+lamp
My current solution is to write different actions and views for these routes. All views are listing products with a partial view but there are some differences like filtering or car selection (which I presume I can handle this again with another partial view)
@if(Model.ShowCarSelection)
{
@Html.Partial("_CarSelection")
}
I wonder how do you handle scenarios like this. For example what about something like this:
[HttpGet, Route("browse"), Route("/{make}/{model}"), Route("categorySlug")]
public ActionResult List(string make, string model, string categorySlug, int page = 1, string sort, string filter)
{
var listVM = new ListVM();
if(!string.IsNullOrEmpty(categorySlug))
listVM.Products = productService.GetByCategorySlug(categorySlug);
else if (!string.IsNullOrEmpty(make))
listVM.Products = productService.GetByMakeAndModel(make, model);
// other things like filtering, sorting, preparing car selection partial view model etc.
return View();
}
But this will make a really long action which I will make me feel sad(bad).
Anyone dealt with something like this can give me directions ?