예제 #1
0
        public string CheckTypeOfUserAndRegisterIt(ApplicationUser user)
        {
            String isStaff;
            String isStudent;

            staffService           = new StaffService();
            uniStudentsListService = new UniversityStudentsListService();

            isStudent = uniStudentsListService.CheckIfIsStudentAndRegisterIt(user);

            if (isStudent != null)
            {
                return(isStudent);
            }
            else
            {
                isStaff = staffService.CheckIfIsStaff(user);

                if (isStaff != null)
                {
                    return(isStaff);
                }
            }

            return(null);
        }
예제 #2
0
        public Student UpdateStudentById(int id, Student student)
        {
            uniService = new UniversityStudentsListService();

            Student studentToUpdate = db.Students.Find(id);

            studentToUpdate.Name = student.Name;

            db.SaveChanges();

            // update uni student name
            uniService.ChangeNameByStudentId(studentToUpdate.Email, student.Name);

            return(studentToUpdate);
        }
예제 #3
0
        public Student AddStudent(UniversityStudentsList student)
        {
            uniService = new UniversityStudentsListService();

            Student studentToRegister = new Student()
            {
                Name       = student.Name,
                Email      = student.Email,
                CourseId   = student.CourseId,
                isEnrolled = true
            };

            db.Students.Add(studentToRegister);
            db.SaveChanges();

            uniService.UpdateUniversityStudentEnrollment(student);

            return(studentToRegister);
        }
예제 #4
0
        public Student RegisterStudent(UniversityStudentsList student)
        {
            courseSubjectService          = new CourseSubjectService();
            studentService                = new StudentService();
            studentSubjectService         = new StudentSubjectService();
            universityStudentsListService = new UniversityStudentsListService();


            Student studentToRegister = new Student();

            // adding and saving student to db, changing university list isEnrolled to true
            studentToRegister = studentService.AddStudent(student);

            //populate student with student subjects
            ICollection <Subject> studentCourseSubjects = new List <Subject>();

            studentCourseSubjects = courseSubjectService.GetSubjectsFromCourse(studentToRegister.CourseId);

            studentSubjectService.CreateStudentSubjectList(studentCourseSubjects.ToList(),
                                                           studentToRegister);

            return(studentToRegister);
        }