title: passing multiple models to controller to build ViewModel
body: <p>So I'm consuming a RESTFul API to get the data I need. This API returns json and i converted this to C# models. The API returns some general info about a vendor and an array with products. The array of products also consists out of arrays for pricing information and product availability etc... </p>
  
  <p>The problem im facing is that when a product is selected by a user to buy i have to gather specific information out of the different array's. Currently I've made a ViewModel for the data that needs to be send to process the order. This is done by binding the actual data using hidden fields and use a HttpPost from the view, resulting in +/- 30 hidden fields to set the proper data values.</p>
  
  <p>I'm kinda new to MVC and this seems dirty. I thought i would be able to pass the models(for example the VendorModel,ProductModel,PricingModel,AvailabilityModel) from the view(with a POST) to the controller and create the ViewModel(based on the models send) so that i can send that to the API.</p>
  
  <p>Is this actually how it should be done or is my design faulty and should i approach this differently?</p>
  
  <p>A side note: One of the things i found is that most people suggest to use an identifier to get the data you need but the problem is that the API doesn't have the right calls to get Product, Pricing, Availability data based on Id, its just one big object with array's based on the search query.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>So after some information i decided to try out nested models and created a viewmodel like this:</p>
  
  <pre><code>public class TestViewModel
  {
      public TestViewModel()
      {
          productInfo = new ProductInfo();
      }
  
      public ProductInfo productInfo { get; set; }   
  }
  </code></pre>
  
  <p>My view is like this(super simpel):</p>
  
  <pre><code>@using (Html.BeginForm("CreateOrder","Products"))
  {
      //Vender info etc...
  
      //This is how i render partial view now:
      {Html.RenderPartial("Info/ProductInfo", Product.ProductInformation.ProductInfo);} 
  
      &lt;input type="submit" value="Order" class="btn btn-default" /&gt;
  }
  </code></pre>
  
  <p>My controller(TestViewModel.ProductInfo is always null): </p>
  
  <pre><code>public ActionResult MakeReservation(TestViewModel testViewModel)
  {
      //Doesnt do anything just debugging TestViewModel
      return View();
  }
  </code></pre>
  
  <p>I'm not posting any inputs but just want to pass the modal with the data to the controller. How will MVC know which data to bind, because now it doesnt bind. Do i have to bind it myself somehow?</p>