public static void CoursesAvailableForStudent(string id)
        {
            int           level = context.students.FirstOrDefault(s => s.student_ID == id).student_level;
            List <course> coursesAvailabaleForStudent = (from c in context.courses
                                                         where c.course_level == level
                                                         select c).ToList();

            //List<string> RemainingCourses = (from c in context.student_available_course
            //                                 where c.student_ID == id
            //                                 select c.course_ID).ToList();
            //List<prequest_course> PC = context.prequest_course.ToList();
            //foreach (var item in coursesAvailabaleForStudent)
            //{
            //    foreach (var itemPC in PC)
            //    {
            //        if ()
            //}
            //}

            foreach (var item in coursesAvailabaleForStudent)
            {
                student_available_course SAC = new student_available_course();
                SAC.student_ID = id;
                SAC.course_ID  = item.course_code;
                context.student_available_course.Add(SAC);
                context.SaveChanges();
            }
        }
 public ActionResult insertDegreesToStudent(student_degree SD, string status)
 {
     if (context.students.FirstOrDefault(s => s.student_ID == SD.student_ID) != null && context.courses.FirstOrDefault(c => c.course_code == SD.course_ID) != null && (SD.activites + SD.midterm + SD.practical <= 50) && (SD.activites + SD.final + SD.midterm + SD.practical <= 100))
     {
         student_degree newSD = new student_degree {
             student_ID = SD.student_ID, course_ID = SD.course_ID, final = SD.final, practical = SD.practical, midterm = SD.midterm, activites = SD.activites
         };
         newSD.GPA          = Convert.ToDecimal(CoursesFCI.CalGPA(Convert.ToDouble(newSD.activites + newSD.final + newSD.midterm + newSD.practical)));
         newSD.appreciation = CoursesFCI.CalAppreciation(Convert.ToDouble(newSD.GPA));
         context.student_degree.Add(newSD);
         context.SaveChanges();
         bool isSuccess = CoursesFCI.isSuccess(newSD.appreciation);
         if (isSuccess)
         {
             student_available_course RemoveCourse = context.student_available_course.FirstOrDefault(c => c.course_ID == newSD.course_ID);
             context.student_available_course.Remove(RemoveCourse);
             context.SaveChanges();
         }
         if (status == "true")
         {
         }
         return(RedirectToAction("../studentInformation/operationsucceeded"));
     }
     return(View("insertDegreesToStudent"));
 }
 public ActionResult registerToStudent(string id, CoursesAvailabelToStudentViewModel CATS)
 {
     foreach (var item in CATS.coursesAvailableList)
     {
         student_available_course SAC = new student_available_course();
         SAC.course_ID  = context.courses.FirstOrDefault(c => c.course_name == item).course_code;
         SAC.student_ID = context.students.FirstOrDefault(s => s.student_ID == id).student_ID;
         context.student_available_course.Add(SAC);
         context.SaveChanges();
     }
     return(RedirectToAction("getStudent"));
 }