title: Return 2 lists from one model to a view in MVC
body: <p>I am new to MVC, and I am struggling with viewmodels. I would like to return 2 lists from the same model into one view.  I will need 2 foreach loops to show records of a different "status" on one view. Because both lists are coming from one model, is it necessary to create a viewmodel?  </p>
  
  <p>I have tried the following, but my view is not finding the item type for each list.</p>
  
  <pre><code> public class PipelineViewModel
   {
      public int LeadID { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public string Status{ get; set; }
      public string LoanAgent{ get; set; }
  
      public List&lt;WebLead&gt; PipeNewLeads { get; set; }
      public List&lt;WebLead&gt; PipeDispLeads { get; set; }
  }
  </code></pre>
  
  <p>Note the List is domain model for the table I am pulling the lists from. Is that correct?</p>
  
  <p>Next in my controller:</p>
  
  <pre><code>    public ActionResult Index(string LoanAgent)
      {
          var viewModel = new PipelineViewModel
          {
              PipeNewLeads = db.WebLeads
              .Where(l =&gt; l.LoanAgent.Equals(LoanAgent) &amp;&amp; l.Status.Equals("New")).ToList(),
               PipeDispLeads = db.WebLeads
              .Where(l =&gt; l.LoanAgent.Equals(LoanAgent) &amp;&amp; l.Status.Equals("Disp")).ToList(),
           };
          return View(viewModel);
  </code></pre>
  
  <p>I know that the controller is wrong.  I need to be referencing the viewmodel somehow, but I have tried a few ways and keep getting errors.</p>
  
  <p>In the view, I used</p>
  
  <pre><code>@model LoanModule.ViewModels.PipelineViewModel
  </code></pre>
  
  <p>and I tried to call each list like this, but it didn't work.</p>
  
  <pre><code>@foreach (var item in Model.PipeNewLead)
  @foreach (var item in Model.DispNewLead)
  </code></pre>
  
  <p>I think I am almost there, but I am not sure what I am doing wrong in the controller. I would appreciate any help or references!</p>