Exemplo n.º 1
0
        /// <summary>
        /// Admin page with data mapped to TeacherID in "teachers" table
        /// Data includes: name, email, teacher's classes schedule
        /// </summary>
        /// <param name="teacherid">TeacherID of teacher to pull data of</param>
        /// <returns>View: ViewTeacher?teacherid</returns>
        public async Task <IActionResult> ViewTeacher(int teacherid)
        {
            ViewTeacherVM TeacherToView = _adminRepository.GetTeacher(teacherid);

            TeacherToView.Classes = _adminRepository.GetTeacherSchedule(teacherid);

            return(await Task.Run(() => View(TeacherToView)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets data of teacher mapped to teacherid
        /// </summary>
        /// <param name="teacherid">ID of teacher to get data of</param>
        /// <returns>ViewTeacherVM with data of teacher</returns>
        public ViewTeacherVM GetTeacher(int teacherid)
        {
            var teacher = (from teachers in _context.Teachers
                           select new
            {
                teachers.TeacherId,
                teachers.TeacherFirstName,
                teachers.TeacherLastName,
                teachers.Email
            }).Where(t => t.TeacherId == teacherid).FirstOrDefault();

            ViewTeacherVM teacherToView = new ViewTeacherVM
            {
                TeacherId        = teacher.TeacherId,
                TeacherFirstName = teacher.TeacherFirstName,
                TeacherLastName  = teacher.TeacherLastName,
                Email            = teacher.Email
            };

            return(teacherToView);
        }