public async Task InitCourses() { TotalStudents = await courseService.GetTotalStudentsFromInstructorsCourses <int>(User.UserID); TotalCourses = await courseService.GetTotalInstructorsCourses <int>(User.UserID); TotalRating = await courseService.GetAverageInstructorsCoursesRating <float>(User.UserID); try { CourseSearchRequest request = new CourseSearchRequest() { UserID = User.UserID }; InstructorList.Clear(); var courses = await courseService.Get <List <MCourse> >(request); foreach (var course in courses) { if (courses.Count > 0) { InstructorList.Add(new CourseVM(course)); } } } catch (Exception) { } }
/// <summary> /// Gets a list of Instructors /// </summary> /// <returns>List of Instructors</returns> public static InstructorList GetItem() { InstructorList myInstructorList = null; using (SqlConnection myConnection = new SqlConnection(AppSettings.ConnectionString)) { SqlCommand myCommand = new SqlCommand("spSelectInstructorList", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myConnection.Open(); using (SqlDataReader myDataReader = myCommand.ExecuteReader()) { if (myDataReader.HasRows) { myInstructorList = new InstructorList(); while (myDataReader.Read()) { myInstructorList.Add(FillRecord(myDataReader)); } } myDataReader.Close(); } myConnection.Close(); } return(myInstructorList); }
public bool AddInstructor(CSPersonnel p) { if (InstructorList.Contains(p.ID)) { return(true); } if (InstructorList.Count >= MAX_INSTRUCTOR_NUM) { return(false); } if (TraineeNpcId == p.ID) { if (m_Counter != null) { StopCounter(); } TraineeNpcId = -1; } TraineeList.Remove(p.ID); InstructorList.Add(p.ID); p.trainerType = ETrainerType.Instructor; UpdateUI(); return(true); }
internal static InstructorList DataTableToTitleList(DataTable Dt) { InstructorList instructors = new InstructorList(); try { foreach (DataRow item in Dt.Rows) { instructors.Add(DataRowToTitle(item)); } } catch { } return(instructors); }
//Responsible of submitting the instructor with all its details to the database private void ButtonSubmit_Click(object sender, EventArgs e) { //Check if there is an empty field bool isValid = true; foreach (Control ctr in Controls) { if (ctr is TextBox) { if (ctr.Text == "" || ctr.Text is null) { isValid = false; } } } //Check if there is an empty field that wasn't put if (isValid) { Instructor instructor = new Instructor(); //Taking all the details from text boxes (submitted by user) and fill it in an Instructor object instructor.InstructorID = textBoxID.Text.ToString(); instructor.FirstName = textBoxFname.Text; instructor.LastName = textBoxlName.Text; instructor.HireDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); instructor.Password = textBoxPasswd.Text; //Add the instructor instructorList.Add(instructor); if (instructor.getValid()) { //Show confirmation message MessageBox.Show("Instructor Added Successfully!"); Clear(); } else { MessageBox.Show(instructor.geterrorMessage()); } } else { MessageBox.Show("A field is empty"); } }
/// <summary> /// Gets a list of Instructors /// </summary> /// <returns>List of Instructors</returns> public static InstructorList GetItem() { InstructorList myInstructorList = null; using (SqlConnection myConnection = new SqlConnection(AppSettings.ConnectionString)) { SqlCommand myCommand = new SqlCommand("spSelectInstructorList", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myConnection.Open(); using (SqlDataReader myDataReader = myCommand.ExecuteReader()) { if (myDataReader.HasRows) { myInstructorList = new InstructorList(); while (myDataReader.Read()) { myInstructorList.Add(FillRecord(myDataReader)); } } myDataReader.Close(); } myConnection.Close(); } return myInstructorList; }
public async Task InitLectures() { Rating = await courseService.GetAverageRating <float>(Course.CourseID); Total = await courseService.GetTotalStudents <int>(Course.CourseID); videoLectureList.Clear(); try { var lectures = await courseService.GetLectures <List <MVideoLecture> >(Course.CourseID, null); if (lectures.Count() != 0) { foreach (var lecture in lectures) { videoLectureList.Add(lecture); var req = new SectionSearchRequest { SectionID = lecture.SectionID }; var sections = await sectionService.Get <List <MSection> >(req); foreach (var section in sections) { if (lecture.SectionID == section.SectionID) { sectionList.Add(section); } } } foreach (var x in sectionList) { var DoesItContain = NewsectionList.Where(m => m.SectionID == x.SectionID).Any(); if (DoesItContain == false) { NewsectionList.Add(x); } } } CourseSearchRequest request = new CourseSearchRequest() { UserID = Course.User.UserID }; InstructorList.Clear(); var courses = await courseService.Get <List <MCourse> >(request); foreach (var course in courses) { if (courses.Count > 0) { if (course.CourseID != Course.CourseID) { InstructorList.Add(new CourseVM(course)); } } else { InstructorList.Add(new CourseVM(course)); } } } catch (Exception) { } }