title: Multiple ViewModels in View asp.net MVC
body: <p>I am new to asp.net mvc and viewmodels are new to me as well. I have a view that shows products.  In the view I want to show all the Products in one div.
  then in another div I want to show just the featuredProducts and in another div the Toprated. I am trying to use different viewmodels for each because I am going to use these again on different page. Is this the correct way to go about doing this and if not what is.  Also how can I do this with viewmodels just for the exercise.</p>
  
  <p>Domain Model</p>
  
  <pre><code>public class Product
  {
      public int ProductId { get; set; }
      public string SKU { get; set; }
      public string Name { get; set; }
      public string Title { get; set; }
      public string Description { get; set; }
      public Boolean FeaturedProduct { get; set; }
      public Boolean NewProduct { get; set; }
      public Boolean TopRated { get; set; }
      public Boolean BestSellers { get; set; }
  }
  </code></pre>
  
  <p>ViewModelProductsMain (Parent)</p>
  
  <pre><code>public class ViewModelProductsMain 
  {
      public ViewModelProducts Products{ get; set; }
      public ViewModelTopRated TopRated{ get; set; }
      public ViewModelFeatured Featured{ get; set; }
  }
  </code></pre>
  
  <p>ViewModels (children)</p>
  
  <pre><code>public class  ViewModelProducts (Child)
  //all products
  {
      public int ProductId { get; set; }
      public string SKU { get; set; }
      public string Name { get; set; }
      public string Title { get; set; }
      public string Description { get; set; }
  }
  public class ViewModelTopRated (Child)
  //all products with TopRated true
  {
      public int ProductId { get; set; }
      public string SKU { get; set; }
      public string Name { get; set; }
      public string Title { get; set; }
      public string Description { get; set; }
  }
  
  public class ViewModelFeatured (Child)
  //all products with Featured true
  {
      public int ProductId { get; set; }
      public string SKU { get; set; }
      public string Name { get; set; }
      public string Title { get; set; }
      public string Description { get; set; }
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>public ActionResult Index()
  {
      //How do I, instantiate and populate the model
      var model = new ViewModelProductsMain ();
      return View(model);
  }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>@model IEnumerable&lt;myProject.ViewModels.ViewModelProductsMain &gt;
  </code></pre>