Exemple #1
0
        private void SAMPLEProcessKBSearch(HttpContext context, int parentID, int userID)
        {
            string term = context.Request.QueryString["q"];

            //Sample code to show you how to easily get SQL to JSON
            SqlCommand command = new SqlCommand();

            command.CommandText = "SELECT Name, TicketNumber, TicketID FROM Tickets WHERE TicketID = @TicketID";
            command.Parameters.AddWithValue("TicketID", 1637556);
            ExpandoObject[] tickets = SqlExecutor.GetExpandoObject(LoginUser.Anonymous, command);

            command             = new SqlCommand();
            command.CommandText = "SELECT Description FROM Actions WHERE TicketID = @TicketID";
            command.Parameters.AddWithValue("TicketID", 1637556);
            ExpandoObject[] actions = SqlExecutor.GetExpandoObject(LoginUser.Anonymous, command);

            (tickets[0] as dynamic).Actions = actions;

            dynamic result = new ExpandoObject();

            result.Term     = term;
            result.UserID   = userID;
            result.ParentID = parentID;
            result.Tickets  = tickets;

            WriteJson(context, result);
        }