public ActionResult SearchPage(string id) { if (Request.QueryString.Get("page") != null) { ViewBag.page = int.Parse(Request.QueryString.Get("page")); } ViewBag.Search = id; ViewBag.title = "Search Result"; VideoBll videoBll = new VideoBll(); //ViewBag.Videos = videoBll.GetVideosSearchByTitle(id); if (id == null) { return(RedirectToAction("NotFound", "Home", new { message = "Search query not specified - Invalid URL" })); } return(View(videoBll.GetVideosSearchByTitle(id.ToLower()))); }
public ActionResult Search(FormCollection collection, string id) { if (Request.QueryString.Get("page") != null) { ViewBag.page = int.Parse(Request.QueryString.Get("page")); } ViewBag.Title = "Search for " + id; ViewBag.Search = id; id = id.ToLower(); // SqlConnection connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=PAP1;Integrated Security=True"); // SqlDataAdapter dataAdapter = new SqlDataAdapter( //"SELECT * FROM Video Where lower(title) Like '%" + id + "%'" //+ "Order By (Case When lower(title)='" + id + "' Then 1 When lower(title)='" + id + "%' Then 2 Else 3 End)" //, connection); // DataSet dataSet = new DataSet(); // dataAdapter.Fill(dataSet); // List<_Video> Videos = new List<_Video>(); // foreach (DataRow row in dataSet.Tables[0].Rows) // { // _Video V = new _Video(); // V.id = int.Parse(row["id"].ToString()); // V.title = row["title"].ToString(); // V.username = row["username"].ToString(); // V.discriminator = int.Parse(row["discriminator"].ToString()); // V.videoFile = row["videoFile"].ToString(); // V.thumbnail = row["thumbnail"].ToString(); // Videos.Add(V); // } VideoBll videoBll = new VideoBll(); ViewBag.Videos = videoBll.GetVideosSearchByTitle(id); return(View()); }