Exemplo n.º 1
0
        public ActionResult GetCoursesSchedule()
        {
            if (Session["Permission"] == null || Session["Permission"].ToString() != "Lecturer")
            {
                return(View("~/Views/Error.cshtml"));
            }
            var lecturerDal = new LecturerDal();
            var courseDal   = new CourseDal();
            var courses     = new List <Course>();
            var id          = Session["UserID"].ToString();
            var lecturers   = (from x
                               in lecturerDal.Lecturers
                               where x.LecturerId.Equals(id)
                               select x).ToList();

            for (int i = 0; i < lecturers.Count(); i++)
            {
                var t = lecturers[i].CourseName;
                courses.Add((from x
                             in courseDal.Courses
                             where x.CourseName.Equals(t)
                             select x).SingleOrDefault());
            }
            return(View("ShowCoursesSchedule", new CourseViewModel {
                Courses = courses
            }));
        }
Exemplo n.º 2
0
        public ActionResult Faculty(Account account)
        {
            string id = account.ID;

            faculy_id = id;
            var LecturerDal = new LecturerDal();
            var LecturerObj = (from x in LecturerDal.Lecturer select x).ToList <Lecturer>();
            var FacultyDal  = new FacultyDal();
            var FacultyObj  = (from x in FacultyDal.Faculty where x.ID.Equals(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        = account.ID,
                FirstName = FacultyObj[0].FirstName,
                LastName  = FacultyObj[0].LastName
            };
            FacultyViewModel facultyViewModel = new FacultyViewModel()
            {
                faculty       = faculty,
                Coursesdata   = CourseObj,
                Studentsdata  = StudentsObj,
                LecturersData = LecturerObj
            };

            return(View(facultyViewModel));
        }
Exemplo n.º 3
0
        public ActionResult Submit(Course course)
        {
            ScheduleDal dal         = new ScheduleDal();
            LecturerDal lecturerDal = new LecturerDal();
            CourseDal   courseDal   = new CourseDal();

            if (!lecturerDal.IsFound(course.Lecturer))
            {
                ViewBag.error = "  the lecturer is not found";
                return(View("AddCourse"));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    Session["shid"] = (dal.schedules.Count() + 1).ToString();
                    course.shid     = Session["shid"].ToString();
                    courseDal.courses.Add(course);
                    courseDal.SaveChanges();
                    return(RedirectToAction("addschule"));
                }
                catch (Exception)
                {
                    ViewBag.error1 = "Enter another course number";

                    return(View("AddCourse"));
                }

                //throw;
            }

            else
            {
                // ViewData["error1"] = "Enter another course number";
                ViewBag.error1 = "Enter another course number";
            }
            return(View("AddCourse"));
            //if(ModelState.IsValid)
            //    return View(Content("HI EVERY THING IS OK BYBY"));
            //else
            //{
            //    return RedirectToAction("AddCourse");
            //}



            //return View("ShowUsers");
            // }
        }
Exemplo n.º 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));
        }
Exemplo n.º 5
0
        public ActionResult Lecturer(Account account)
        {
            string   id            = account.ID;
            var      CoursesDal    = new CoursesDal();
            var      CourseDetails = (from x in CoursesDal.Courses where x.LectID.Equals(id) select x).ToList <Courses>();
            var      LecturerDal   = new LecturerDal();
            var      LecturerUser  = (from x in LecturerDal.Lecturer where x.ID.Equals(id) select x).ToList <Lecturer>();
            Lecturer lecturer      = new Lecturer()
            {
                ID        = account.ID,
                FirstName = LecturerUser[0].FirstName,
                LastName  = LecturerUser[0].LastName
            };


            LecturerViewModel lecturerViewModel = new LecturerViewModel()
            {
                lecturer = lecturer,
                courses  = CourseDetails
            };

            return(View(lecturerViewModel));
        }
Exemplo n.º 6
0
 public ActionResult Menu()
 {
     if (Session["Permission"] == null || Session["Permission"].ToString() != "Lecturer")
     {
         return(View("~/Views/Error.cshtml"));
     }
     if (Request.Form["ShowCoursesSchedule"] != null)
     {
         return(RedirectToAction("GetCoursesSchedule"));
     }
     if (Request.Form["ShowCourseStudents"] != null)
     {
         var lecturerDal = new LecturerDal();
         var id          = Session["UserID"].ToString();
         var courses     = (from x
                            in lecturerDal.Lecturers
                            where x.LecturerId.Equals(id)
                            select x.CourseName).ToList();
         Session["ListCourses"] = courses;
         return(View("ShowCourseStudents"));
     }
     return(View("LecturerMenu"));
 }
Exemplo n.º 7
0
        public ActionResult ChangeLecturer(string CourseName, string LectID)
        {
            var LecturerDal = new LecturerDal();
            var LecturerObj = (from x in LecturerDal.Lecturer select x).ToList <Lecturer>();
            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
            };
            var CourseObj3 = (from x in CourseDal.Courses where x.LectID.Equals(LectID) select x).ToList <Courses>();
            var CourseObj2 = (from x in CourseDal.Courses where x.CourseName.Equals(CourseName) select x).First <Courses>();

            if (CourseObj2.LectID != LectID && CourseObj2 != null)
            {
                Courses c = new Courses()
                {
                    CourseName = CourseObj2.CourseName,
                    Classroom  = CourseObj2.Classroom,
                    Day        = CourseObj2.Day,
                    Hour       = CourseObj2.Hour,
                    MoedA      = CourseObj2.MoedA,
                    MoedB      = CourseObj2.MoedB,
                    LectID     = LectID
                };
                int cnt = 0;
                foreach (Courses c_2 in CourseObj3)
                {
                    if (c_2.Day == c.Day && c_2.Hour == c.Hour)
                    {
                        cnt++;
                    }
                }
                if (cnt == 0)
                {
                    CourseDal.Courses.Remove(CourseObj2);
                    CourseDal.Courses.Add(c);
                    CourseDal.SaveChanges();
                }
                else
                {
                    ViewBag.ErrorMessage3 = "The course lecturer is already registered at this time";
                    return(View("Faculty", facultyViewModel));
                }
            }
            return(View("Faculty", facultyViewModel));
        }
Exemplo n.º 8
0
        public ActionResult EditCourse(string CourseName, string MoedA, string MoedB, string Day, string Hour, string Classroom)
        {
            var LecturerDal = new LecturerDal();
            var LecturerObj = (from x in LecturerDal.Lecturer select x).ToList <Lecturer>();
            var CourseDal   = new CoursesDal();
            var CourseObj2  = (from x in CourseDal.Courses where x.CourseName.Equals(CourseName) select x).First <Courses>();
            var FacultyDal  = new FacultyDal();
            var FacultyObj  = (from x in FacultyDal.Faculty where x.ID.Equals(faculy_id) select x).ToList <Faculty>();
            var CoursesObj  = (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   = CoursesObj,
                Studentsdata  = StudentsObj,
                LecturersData = LecturerObj
            };
            Courses CourseObj = new Courses()
            {
                CourseName = CourseName,
                Day        = Day,
                Hour       = Hour,
                Classroom  = Classroom,
                MoedA      = MoedA,
                MoedB      = MoedB,
                LectID     = CourseObj2.LectID
            };

            int cnt = 0;

            foreach (Courses c in CourseDal.Courses)
            {
                if (c.Day == CourseObj.Day && c.Hour == CourseObj.Hour && c.Classroom == CourseObj.Classroom)
                {
                    cnt++;
                }
            }
            if (cnt == 1)
            {
                ViewBag.ErrorMessage = "The course lecturer is already registered at this time";
                return(View("Faculty", facultyViewModel));
            }
            else
            {
                CourseDal.Courses.Remove(CourseObj2);
                CourseDal.SaveChanges();
                CourseDal.Courses.Add(CourseObj);
                CourseDal.SaveChanges();
            }

            return(View("Faculty", facultyViewModel));
        }