Exemplo n.º 1
0
        public ActionResult StudentProfile(string id)
        {
            var student = _context.Students.Include(s => s.ApplicationUser).Include(s => s.Specialization).Include(s => s.Group).Include(s => s.Semester).Include(s => s.Year).SingleOrDefault(c => c.ApplicationUserId == id);

            if (student == null)
            {
                return(HttpNotFound());
            }

            var courses = _context.Students.Where(s => s.StudentId == student.StudentId).SelectMany(c => c.Courses).Include(c => c.Teacher.ApplicationUser).Include(s => s.Specialization).Include(s => s.Semester).Include(s => s.Year).ToList();
            var project = _context.Projects.ToList();

            //var studentService = new StudentService();
            //var model = studentService.StudentProfile(student, courses, projects);

            //comentat aici
            //foreach (var course in courses)
            //{
            //    var project = projects.SingleOrDefault(p => p. == course.CourseId);
            //    if (project != null)
            //    {
            //        projects.Add(project);
            //    }

            //}

            var studentCoursesProjects = new StudentCoursesProjectsViewModel
            {
                Student  = student,
                Courses  = courses,
                Projects = project
            };

            return(View("StudentProfile", studentCoursesProjects));
        }
Exemplo n.º 2
0
        public StudentCoursesProjectsViewModel StudentProfile(Student student, List <Course> courses, List <Project> projects)
        {
            //foreach (var course in courses)
            //{
            //    var project = projects.SingleOrDefault(p => p.CourseId == course.CourseId);
            //    if (project != null)
            //    {
            //        projects.Add(project);
            //    }

            //}

            var studentCoursesProjects = new StudentCoursesProjectsViewModel
            {
                Student  = student,
                Courses  = courses,
                Projects = projects
            };

            return(studentCoursesProjects);
        }