private static Course MapCourse(IDataReader reader) { Course item = new Course(); int startingIndex = 0; item.Id = reader.GetSafeInt32(startingIndex++); item.CourseName = reader.GetSafeString(startingIndex++); item.Length = reader.GetSafeString(startingIndex++); item.Description = reader.GetSafeString(startingIndex++); item.Start = reader.GetSafeDateTime(startingIndex++); item.End = reader.GetSafeDateTime(startingIndex++); item.CourseLength = reader.GetSafeInt32(startingIndex++); item.LearningObjectives = reader.GetSafeString(startingIndex++); item.ExpectedOutcome = reader.GetSafeString(startingIndex++); item.EvaluationCriteria = reader.GetSafeString(startingIndex++); item.Format = reader.GetSafeInt32(startingIndex++); return item; }
public List<Course> GetByUserId(string userId) { List<Course> list = new List<Course>(); Dictionary<int, Course> book = new Dictionary<int, Course>(); DataProvider.ExecuteCmd(GetConnection, "dbo.UserCourses_SelectByUserId" , inputParamMapper: delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@userId", userId); }, map: delegate(IDataReader reader, short set) { if (set == 0) { Course course = new Course(); int startingIndex = 0; course.Id = reader.GetSafeInt32(startingIndex++); course.CourseName = reader.GetSafeString(startingIndex++); //course.Length = reader.GetSafeString(startingIndex++); course.Description = reader.GetSafeString(startingIndex++); course.Start = reader.GetSafeDateTime(startingIndex++); course.End = reader.GetSafeDateTime(startingIndex++); //course.Prereqs = reader.GetSafeString(startingIndex++); list.Add(course); book.Add(course.Id, course); } else if (set == 1) { CourseTag tag = TagMapCourse(reader); Course parentCourse = book[tag.CourseId]; if (parentCourse.Tags == null) { parentCourse.Tags = new List<CourseTag>(); } parentCourse.Tags.Add(tag); } }); return list; }