Beispiel #1
0
        public ActionResult Student(Account account)
        {
            var StudentsDal      = new StudentsDal();
            var username         = account.ID;
            var StudentsUser     = (from x in StudentsDal.Students where x.ID.Equals(username) select x).ToList <Student>();
            var StudentCourseDal = new StudentCourseDal();
            var studentCourseObj = (from x in StudentCourseDal.StudentCourses where x.StudentID.Equals(username) select x).ToList <StudentCourse>();

            var            CoursesDal   = new CoursesDal();
            List <Courses> CourseDetail = new List <Courses>();
            Courses        t            = new Courses();

            foreach (StudentCourse y in studentCourseObj)
            {
                t = (from x in CoursesDal.Courses where x.CourseName.Equals(y.CourseName) select x).FirstOrDefault <Courses>();
                CourseDetail.Add(t);
            }
            Student student = new Student()
            {
                ID        = account.ID,
                FirstName = StudentsUser[0].FirstName,
                LastName  = StudentsUser[0].LastName,
            };
            StudentViewModel studentViewModel = new StudentViewModel()
            {
                student        = student,
                courses        = CourseDetail,
                studentCourses = studentCourseObj
            };

            return(View(studentViewModel));
        }
Beispiel #2
0
        public ActionResult ShowStudents(string CourseName)
        {
            string courseName = CourseName;

            CourseN = courseName;
            var StudentCourseDal = new StudentCourseDal();
            var StudentCourseObj = (from x in StudentCourseDal.StudentCourses where x.CourseName.Equals(courseName) select x).ToList <StudentCourse>();

            return(View("ShowStudents", StudentCourseObj));
        }
Beispiel #3
0
        public ActionResult UpdateGrade(string StudentID, string Grade)
        {
            string studentID        = StudentID;
            string newGrade         = Grade;
            var    StudentCourseDal = new StudentCourseDal();
            var    StudentCourseObj = (from x in StudentCourseDal.StudentCourses where x.CourseName.Equals(CourseN) select x).ToList <StudentCourse>();

            foreach (StudentCourse sc in StudentCourseDal.StudentCourses)
            {
                if (sc.CourseName == CourseN && sc.StudentID == studentID)
                {
                    sc.Grade = int.Parse(newGrade);
                }
            }
            StudentCourseDal.SaveChanges();
            return(View("ShowStudents", StudentCourseObj));
        }
Beispiel #4
0
        public ActionResult StudentToCourse(string StudentID, string CourseName)
        {
            var LecturerDal      = new LecturerDal();
            var LecturerObj      = (from x in LecturerDal.Lecturer select x).ToList <Lecturer>();
            var StudentCourseDal = new StudentCourseDal();
            var FacultyDal       = new FacultyDal();
            var FacultyObj       = (from x in FacultyDal.Faculty where x.ID.Equals(faculy_id) select x).ToList <Faculty>();
            var CourseDal        = new CoursesDal();
            var CourseObj        = (from x in CourseDal.Courses select x).ToList <Courses>();
            var StudentsDal      = new StudentsDal();
            var StudentsObj      = (from x in StudentsDal.Students select x).ToList <Student>();

            Faculty faculty = new Faculty()

            {
                ID        = faculy_id,
                FirstName = FacultyObj[0].FirstName,
                LastName  = FacultyObj[0].LastName
            };
            FacultyViewModel facultyViewModel = new FacultyViewModel()
            {
                faculty       = faculty,
                Coursesdata   = CourseObj,
                Studentsdata  = StudentsObj,
                LecturersData = LecturerObj
            };

            StudentCourse sc = new StudentCourse()
            {
                CourseName = CourseName,
                StudentID  = StudentID,
            };

            if (StudentCourseDal.StudentCourses.Find(sc.StudentID, sc.CourseName) == null)
            {
                StudentCourseDal.StudentCourses.Add(sc);
                StudentCourseDal.SaveChanges();
            }
            else
            {
                ViewBag.ErrorMessage2 = "This student is already assigned to this course!";
                return(View("Faculty", facultyViewModel));
            }
            return(View("Faculty", facultyViewModel));
        }