private static List <Course> search_courses_by_specialization_tag(List <SearchToken> search_tokens) { using (SqlConnection con = new SqlConnection(Database.connection_string)) { con.Open(); SqlCommand com = new SqlCommand("Search", con); com.CommandType = CommandType.StoredProcedure; int i = 0; List <string> search_soundex = new List <string>(); foreach (var item in search_tokens) { com.Parameters.AddWithValue("@tag" + i, item.soundex); search_soundex.Add(item.soundex); i++; } com.Parameters.AddWithValue("@Action", "SearchCoursesBySpecializationTag"); SQL_Utility.Stored_Procedure(ref com, search_soundex); SqlDataReader rdr = com.ExecuteReader(); List <Course> courses = new List <Course>(); while (rdr.Read()) { Course c = Course_crud.parse_course(rdr); Branch_crud.getCourseCenteNamerAndBranchName(c); c.specializations = Course_crud.getCourseSpecialization(c.course_type_id); courses.Add(c); } return(courses); } }
public static Branch getBranchByID(long id) { using (SqlConnection con = new SqlConnection(Database.connection_string)) { con.Open(); SqlCommand com = new SqlCommand("Branch", con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@id", id); com.Parameters.AddWithValue("@Action", "GetBranchByID"); SQL_Utility.Stored_Procedure(ref com); SqlDataReader rdr = com.ExecuteReader(); Branch branch = null; branch = parse_Branch_complete(rdr); branch.courses = Course_crud.getCoursesByBranchID(id); return(branch); } }