public ActionResult Search(Search searchableStuff) { string keyword = searchableStuff.keyword; List<string> tablesToSearch = new List<string>(); if (!(searchableStuff.table==null)) { tablesToSearch.Add(searchableStuff.table); } Search searchResult = new Search(); List<List<object>> tablesWillSearch = new List<List<object>>(); if (tablesToSearch.Count()==0) { tablesWillSearch = DataAccess.DataAccess.ListTables(); } else { foreach (string table in tablesToSearch) { List<object> list = new List<object> { table }; tablesWillSearch.Add(list); } } foreach (List<object> tables in tablesWillSearch) { if (!(tables[0].ToString().StartsWith("Asp") || tables[0].ToString().StartsWith("__"))) { List<List<object>> tableResults = TableSearch(tables[0], keyword); foreach (List<object> result in tableResults) { switch (tables[0].ToString()) { case "Messages": Message m = new Message(); m.id = (int)result[0]; m.from = (string)result[1]; m.to = (string)result[2]; m.body = (string)result[3]; m.project = (string)result[4]; m.time = (DateTime)result[5]; searchResult.messages.Add(m); break; case "Projects": Project p = new Project(); p.id = (int)result[0]; p.name = (string)result[1]; p.description = (string)result[2]; break; case "Events": Event e = new Event(); e.id = (int)result[0]; e.calendarId = (int)result[1]; e.title = (string)result[2]; e.description = (string)result[3]; e.occurencetime = (DateTime)result[4]; e.time = (DateTime)result[5]; searchResult.events.Add(e); break; case "User": User u = new User(); u.id = (int)result[0]; break; default: Other o = new Other(); o.result = result; o.table = (string)tables[0]; searchResult.others.Add(o); break; } } } } return View(searchResult); }
public ActionResult Tester() { Project project = new Project(); project.calendars = new List<Calendar>(); project.auths = new List<ProjectAuth>(); project.description = "This is a static description not being pulled from the database."; project.name = "This is a static name"; List<List<object>> calendarResult = DataAccess.DataAccess.Read(Build.StringArray("Calendars"), Build.StringArray("id"), Build.StringArray("id = 1")); foreach (List<object> calendar in calendarResult) { Calendar cal = new Calendar(); cal.id = (int)calendar[0]; cal.events = new List<Event>(); List<List<object>> eventResult = DataAccess.DataAccess.Read(Build.StringArray("Events"), Build.StringArray("id", "calendar_id", "title", "description", "time"), Build.StringArray("calendar_id = " + cal.id)); foreach (List<object> evt in eventResult) { Event e = new Event(); e.id = (int)evt[0]; e.calendarId = (int)evt[1]; e.title = (string)evt[2]; e.description = (string)evt[3]; e.time = (DateTime)evt[4]; cal.events.Add(e); } project.calendars.Add(cal); } return View("Mock", project); }
public ActionResult Project(int id) { // if (!Authorized(id)) // return Redirect("/"); Session["ProjectViewed"] = id; NotificationController _notificationController = new NotificationController(); Project project = new Project(); project.calendars = new List<Calendar>(); project.auths = new List<ProjectAuth>(); project.description = "This is a static description not being pulled from the database."; project.name = "This is a static name"; project.chat = Chat(); //project.notifications = @{Html.RenderAction("NotificationView");} List<List<object>> calendarResult = DataAccess.DataAccess.Read(Build.StringArray("Calendars"), Build.StringArray("id"), Build.StringArray("project_id = " + Session["ProjectViewed"])); foreach (List<object> calendar in calendarResult) { Calendar cal = new Calendar(); cal.id = (int)calendar[0]; Session["Calendar"] = cal.id; cal.events = new List<Event>(); List<List<object>> eventResult = DataAccess.DataAccess.Read(Build.StringArray("Events"), Build.StringArray("id", "calendar_id", "title", "description", "_time"), Build.StringArray("calendar_id = " + cal.id)); foreach (List<object> evt in eventResult) { Event e = new Event(); e.id = (int)evt[0]; e.calendarId = (int)evt[1]; e.title = (string)evt[2]; e.description = (string)evt[3]; e.time = (DateTime)evt[4]; cal.events.Add(e); } project.calendars.Add(cal); } return View("Mock", project); }