title: How do I add multiple filters to my API (MVC)
body: <p>I'm building an app in C# (which is a little rusty) and I'm using an AJAX call to return some data from my database. I want to add some filtering to this by passing an object to the controller.</p>
  
  <p>I've got it working when just one filter is used but I'm struggling when it comes to multiple filters. How do I set this up so I can check to see if that filter is being used and then filter the database on it?</p>
  
  <p>This is my current code:</p>
  
  <p>JS:</p>
  
  <pre><code>dataObj = new Object;
  if (FormData) {
     $.each(FormData, function (index, item) {
         dataObj[item.name] = item.value;                  
     });
  };
  $.ajax({
      url: '@Url.Action("GetCompanies")',
      data: dataObj,
      type: 'GET',
      dataType: 'json',
      success: function (result) {
          //Do stuff with data
      }
  });
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public JsonResult GetCompanies(SearchFilter SearchFilters)
  {
      if (!String.IsNullOrEmpty(SearchFilters.CustomerType) &amp;&amp; SearchFilters.CustomerType != "All")
      {
          var data = _db.Customers.Where(a =&gt; a.Type.Contains(SearchFilters.CustomerType)).ToList();
          var jsonData = Json(data, JsonRequestBehavior.AllowGet);
          return jsonData;
      }
      else
      {
          var data = _db.Customers.ToList();
          var jsonData = Json(data, JsonRequestBehavior.AllowGet);
          return jsonData;
      }
  }
  </code></pre>
  
  <p>Thanks in advance!</p>