title: ASP.NET MVC Conditional ViewModel Abstraction
body: <p>I am new to ASP.NET MVC and I am stuck on a point. I am working on a classified site. My situation is, I have a lot of categories in which a user can post their ads and each ad category have different View. I have created a Controller Action like</p>
  
  <pre><code> public ActionResult PostAd(string CategoryName, string SubCategoryName)
   {
          if(categoryName == "Vehicle" &amp;&amp; SubCategoryName == "Cars")
          {
               var model = new CarAdViewModel();
  
               // set CarAdViewModel properties...
  
               return View("CarAdCreateView", model);
          }
          else if(categoryName == "Vehicle" &amp;&amp; SubCategoryName == "Bikes")
          {
              var model = new BikeAdViewModel();
  
               // set BikeAdViewModel properties...
  
               return View("BikeAdViewModel", model);
          }
          else if(categoryName == "Property" &amp;&amp; SubCategoryName == "RentHouse")
          {
               var model = new RentHouseAdViewModel();
  
               // set RentHouseAdViewModel properties...
  
               return View("RentHouseAdViewModel", model);                 
          }
          else................... so on and so on
   }
  </code></pre>
  
  <p>My problem is I have huge number of Categories and Sub Categories almost 60+. And if I keep on coding like above for 60+ categories and subcategories, my <code>PostAd</code> method is going to blast and become unmanageable. </p>
  
  <p>Please tell me some best practice or pattern which can bring me out of this problem.</p>