//public HomeIndexViewModel CreateModel(string searchTerm, int pageSize, int? page)
        //{
        //    SqlParameter[] param = new SqlParameter[] { new SqlParameter("@search", searchTerm ?? (object)DBNull.Value) };
        //    //The Stored procedure name is searchResult and the input parameter name is @search on the database
        //    IPagedList<tblProduct> data = dbContext.Database.SqlQuery<tblProduct>("searchResult @search", param).ToList().ToPagedList(page ?? 1, pageSize);
        //    return new HomeIndexViewModel
        //    {
        //        ListOfProducts = data
        //    };
        //}

        public HomeIndexViewModel CreateModel(string searchTerm, int pageSize, int?page)
        {
            ProductLogic         logic    = new ProductLogic();
            IPagedList <Product> products = logic.CreateModel(searchTerm, pageSize, page).ToPagedList(page ?? 1, pageSize);;

            return(new HomeIndexViewModel
            {
                ListOfProducts = products
            });
        }