public void GetLessonsInObjective(string userId) { //Get Connection from config file string connString = System.Configuration.ConfigurationManager. ConnectionStrings["killthetest"].ConnectionString; using (SqlConnection connection = new SqlConnection(connString)) { connection.Open(); using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandTimeout = 0; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "dbo.get_objective_lessons"; command.Parameters.AddWithValue("objective_id", ObjectiveId); SqlDataReader dr = command.ExecuteReader(); int lessonId = 0; while (dr.Read()) { lessonId = int.Parse(dr["lesson_id"].ToString()); Lesson l = new Lesson(); l.LessonId = lessonId; l.GetLesson(userId); LessonsInObjective.Add(l); } connection.Close(); } } }
public ActionResult Edit(int id) { KillTheTest.Models.Lesson lesson = new KillTheTest.Models.Lesson(); lesson.LessonId = id; lesson.GetLesson(UserId); return(View("Edit", lesson)); }