Beispiel #1
0
        public void AddStudentToCourse(int studentId, int courseId)
        {
            StudentCourses studentCourses = new StudentCourses()
            {
                CourseId  = courseId,
                StudentId = studentId
            };

            try
            {
                data.studentCourses.Add(studentCourses);
            }
            catch (Exception ex)
            {
                logger.Log(ex.Message);
            }
        }
Beispiel #2
0
        public Courses CreateCourse(Courses course)
        {
            try
            {
                if (course != null)
                {
                    data.courses.Add(course);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                logger.Log(ex.Message);;
            }

            return(course);
        }
Beispiel #3
0
        public Students CreateStudent(Students student)
        {
            try
            {
                if (student != null)
                {
                    data.students.Add(student);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                logger.Log(ex.Message);
            }

            return(student);
        }
Beispiel #4
0
        public IActionResult Report()
        {
            logger.Log("works good");

            var studentsList = university.GetAllStudents();
            var courseList   = university.GetAllCourses();
            var relations    = university.GetAllRelations();

            var reportDetails = report.ReportStudentCourseRelation(studentsList, courseList, relations);

            return(View(reportDetails));
        }
Beispiel #5
0
        public IEnumerable <StudentCourseReportViewModel> ReportStudentCourseRelation(List <Students> studentsList, List <Courses> courseList, List <StudentCourses> relations)
        {
            try
            {
                var report = (from r in relations
                              join s in studentsList on r.StudentId equals s.StudentId
                              join c in courseList on r.CourseId equals c.CourseID
                              select new StudentCourseReportViewModel
                {
                    Student = s.FirstName + " " + s.LastName,
                    Course = c.CourseName
                }).AsEnumerable();

                return(report);
            }
            catch (Exception ex)
            {
                logger.Log(ex.Message);
                return(null);
            }
        }