Search / Filtering multiple fields in mvc 5
<p>I am new in mvc 5. I want to have a search using multiple fields. I have this code but I don't know how to pass the values from the view</p>

<p>View:</p>

<pre><code>&lt;input type="text" name="Id"&gt;
&lt;input type="text" name="Price"&gt;
&lt;input type="text" name="Name"&gt;
</code></pre>

<p>Product Class:</p>

<pre><code>public class Product
{
    public int Id { get; set; }
    public int Price { get; set; }
    public string Name { get; set; }
}
</code></pre>

<p>ProductSearchModel:</p>

<pre><code>public class ProductSearchModel
{
    public int? Id { get; set; }
    public int? PriceFrom { get; set; }
    public int? PriceTo { get; set; }
    public string Name { get; set; }
}
</code></pre>

<p>ProductBusinessLogic:</p>

<pre><code>public class ProductBusinessLogic
{
    private YourDbContext Context;
    public ProductBusinessLogic()
    {
        Context = new YourDbContext();
    }

    public IQueryable&lt;Product&gt; GetProducts(ProductSearchModel searchModel)
    {
        var result = Context.Products.AsQueryable();
        if (searchModel != null)
        {
            if (searchModel.Id.HasValue)
                result = result.Where(x =&gt; x.Id == searchModel.Id);
            if (!string.IsNullOrEmpty(searchModel.Name))
                result = result.Where(x =&gt; x.Name.Contains(searchModel.Name));
            if (searchModel.PriceFrom.HasValue)
                result = result.Where(x =&gt; x.Price &gt;= searchModel.PriceFrom);
            if (searchModel.PriceTo.HasValue)
                result = result.Where(x =&gt; x.Price &lt;= searchModel.PriceTo);
        }
        return result;     
    }
}
</code></pre>

<p>Product Controller:</p>

<pre><code>public ActionResult Index(ProductSearchModel searchModel)
{
    var business = new ProductBusinessLogic();
    var model = business.GetProducts(searchModel);
    return View(model);
}
</code></pre>