-
Notifications
You must be signed in to change notification settings - Fork 2
/
Search.aspx.cs
48 lines (42 loc) · 1.35 KB
/
Search.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Windchime
{
public partial class Search : System.Web.UI.Page
{
protected void btnSearch_Click(object sender, EventArgs e)
{
string args = searchbox.Text.Trim().ToLower();
if (args.CompareTo("") == 0)
{
resultlabel.Text = "Enter Search Params";
return;
}
else
{
using (WindchimeEntities wce = new WindchimeEntities())
{
var results = (from TextVersion t in wce.VersionSet.OfType<TextVersion>()
where t.Text.Contains(args) || t.Assets.Headline.Contains(args) && t.Assets.Approved
select t);
if (results.Count() != 0)
{
resultlabel.Text = "";
foreach (var r in results)
{
resultlabel.Text += r.VersionID;
}
}
else
{
resultlabel.Text = "No Results Returned";
}
}
}
}
}
}