Exemplo n.º 1
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));
        }
Exemplo n.º 2
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));
        }