title: How to bind Single View with Multiple Action in mvc5?
body: <p>Hi i am creating Dashboard for my application . It contain multiple action in controller. I want to bind Single View with multiple action, because i want to display different type of result in view. But Model in single model.That same model is used for every action.</p>
  
  <p><strong>My Model (Customer Type ViewModel)</strong></p>
  
  <pre><code>public class CustomerTypeViewModel
  {
      public System.Guid CustomerID { get; set; }
      public string CustomerName { get; set; }
      public DateTime CreatedDate { get; set; }
      public string SalesCount { get; set; }
      public string CustomerType { get; set; }
  
      public List&lt;View_VisitorsForm&gt; Visits { get; set; }
  }
  }
  </code></pre>
  
  <p><strong>My Controller  (Here two actions there)</strong> </p>
  
  <p>Here i created two action and these two actions doing different calculations and model for these two actions is same(that is CustomerTypeViewModel) and also these two action is redirect to  same view.</p>
  
  <pre><code>   public ActionResult Dashboard()
      {
          List&lt;Customer&gt; n = (from c in db.Customers where c.IsDeleted == false select c).ToList();
          var customertype = string.Empty;
          List&lt;CustomerTypeViewModel&gt; obj = new List&lt;CustomerTypeViewModel&gt;();
          for (var i = 0; i &lt; n.Count; i++)
          {
              var objCustomerName = n[i].DisplayName;
              var objCustomerID = n[i].CustomerID;
              var objCusCreatedDate = n[i].CreatedDate;
              var objNextDate = objCusCreatedDate.GetValueOrDefault().AddDays(120);
              var ObjTodayDate = DateTime.Now.Date;
              var salescount = (from sc in db.SalesOrders where sc.CustomerID == objCustomerID &amp;&amp; sc.CreatedDate &gt;= objCusCreatedDate &amp;&amp; sc.CreatedDate &lt;= objNextDate select sc.SalesOrderID).Count();
              var ordercount = (from oc in db.SalesOrders where oc.CustomerID == objCustomerID &amp;&amp; oc.CreatedDate &gt;= objCusCreatedDate &amp;&amp; oc.CreatedDate &lt;= ObjTodayDate select oc.SalesOrderID).Count();
              if (ordercount &gt;= 3)
              {
                  customertype = "Existing Customer";
              }
              else if (ordercount == 0 &amp;&amp; ordercount &lt;= 0)
              {
                  customertype = "New Customer";
              }
              else if (ordercount &lt;= 2 &amp;&amp; ordercount &gt;= 1)
              {
                  customertype = "Potential Customer";
              }
              obj.Add(new CustomerTypeViewModel()
              {
                  CustomerName = objCustomerName,
                  CustomerType = customertype,
                  SalesCount = ordercount.ToString()
              });
          }
          return View("Dashboard",obj);
      }
      public ActionResult NextFollowup()
      {
          var userID = System.Web.HttpContext.Current.Session["UserID"].ToString();
          var objEmpDepUTID = db.UserRightsSettings.Where(u =&gt; u.UserID.ToString() == userID).Select(e =&gt; new
          {
              objemployeeID = e.EmployeeID,
              objdepartmentID = e.DepartmentID,
              objusertypeID = e.UserTypeID
          }).FirstOrDefault();
  
          var EmployeeID = objEmpDepUTID.objemployeeID;
          var DepartmentID = objEmpDepUTID.objdepartmentID;
          var UserTypeID = objEmpDepUTID.objusertypeID;
          var TodayDate = DateTime.Now.Date;
  
          List&lt;View_VisitorsForm&gt; objVisitorsList = new List&lt;View_VisitorsForm&gt;();
          if (DepartmentID == new Guid("47D2C992-1CB6-44AA-91CA-6AA3C338447E") &amp;&amp;
             (UserTypeID == new Guid("106D02CC-7DC2-42BF-AC6F-D683ADDC1824") ||
             (UserTypeID == new Guid("B3728982-0016-4562-BF73-E9B8B99BD501"))))
          {
              objVisitorsList = db.View_VisitorsForm.Where(X =&gt; X.NextAppointment == TodayDate).ToList();
          }
          else
          {
              objVisitorsList = db.View_VisitorsForm.Where(x =&gt; x.NextAppointment == TodayDate &amp;&amp; x.EmployeeID == EmployeeID).ToList();
          }
          CustomerTypeViewModel objvvm = new CustomerTypeViewModel();
          objvvm.Visits = objVisitorsList;
          return View("Dashboard",objvvm);
      }
  </code></pre>
  
  <p><strong>My View</strong></p>
  
  <p>In this view i gave model as like this means it shows error</p>
  
  <pre><code>   @model CostToWafe.Areas.Sales.Models.CustomerTypeViewModel
     @using CostToWafe.Areas.Sales.Models
  </code></pre>
  
  <p>It shows error near to </p>
  
  <pre><code> @Model.Select(x =&gt; x.CustomerName).Count()
  </code></pre>
  
  <p>if i give model name with IEnumerable like</p>
  
  <pre><code>   @model IEnumerable&lt;CostToWafe.Areas.Sales.Models.CustomerTypeViewModel&gt;
     @using CostToWafe.Areas.Sales.Models
  </code></pre>
  
  <p>it shows error near to  table (Model.Visits)that is </p>
  
  <pre><code>         @foreach (View_VisitorsForm item in Model.Visits)
  </code></pre>
  
  <p><strong>My Full View</strong>       </p>
  
  <pre><code>@model CostToWafe.Areas.Sales.Models.CustomerTypeViewModel
  @using CostToWafe.Areas.Sales.Models
  @{
  ViewBag.Title = "Dashboard";
  Layout = "~/Views/Shared/_Layout.cshtml";
  }
  &lt;div class="container body"&gt;
  &lt;div class="main_container"&gt;
    &lt;div class="right_col" role="main"&gt;
          &lt;!-- top tiles --&gt;
     &lt;div class="row tile_count"&gt;
  
     &lt;div class="right"&gt;
     &lt;span class="count_top"&gt;&lt;i class="fa fa-user"&gt;&lt;/i&gt; Total Customer&lt;/span&gt;
     &lt;div class="count"&gt;@Model.Select(x =&gt; x.CustomerName).Count()&lt;/div&gt;
     &lt;/div&gt;
  
    &lt;div class="right"&gt;
    &lt;span class="count_top"&gt;&lt;i class="fa fa-user"&gt;&lt;/i&gt; Existing Customer&lt;/span&gt;
    &lt;div class="count"&gt;@Model.Where(x =&gt; x.CustomerType == "Existing Customer").Count()&lt;/div&gt;
    &lt;/div&gt;
  
    &lt;div class="row"&gt;
    &lt;table&gt;
    &lt;thead&gt;
           &lt;tr&gt;
                  &lt;th&gt;Employee &lt;/th&gt;
                  &lt;th&gt;Customer Name&lt;/th&gt;
                  &lt;th&gt;Purpose of Visit&lt;/th&gt;
           &lt;/tr&gt;
    &lt;thead&gt;
   &lt;tbody&gt;
            @foreach (View_VisitorsForm item in Model.Visits)
            {
            &lt;tr&gt;
                 &lt;td&gt;@item.Employee;&lt;/td&gt;
                 &lt;td&gt;@item.CustomerName;&lt;/td&gt;
                 &lt;td&gt;@item.POVisit;&lt;/td&gt;
            &lt;/tr&gt;
            }
   &lt;tbody&gt;
   &lt;/table&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>My Question is little long .I tried my level best to explain this issue. Any one understand my question and help me to resolve this issue.</p>
  
  <p>Thanks..</p>