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); }
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); }
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); }
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); }