Example #1
0
        public List<cours> GetCourses( string tid )
        {
            var query = (from x in db.teachers.Where(f => f.tid.Equals(tid))
                         from p in db.courses.Where(g => g.teachers.Contains(x))
                         select p);

            List<cours> data = new List<cours>();

            foreach (var q in query)
            {
                cours c = new cours();
                c.cid = q.cid;
                c.name = q.name;
                data.Add(c);

            }
            return data;

        }
Example #2
0
        public JsonResult GetCourses()
        {
            var query = (from x in db.courses
                         select x);

            List<cours> data = new List<cours>();

            foreach (var q in query)
            {
                cours c = new cours();
                c.cid = q.cid;

                data.Add(c);

            }
            return this.Json(data, JsonRequestBehavior.AllowGet);

        }
Example #3
0
 public ActionResult DeleteCourse(cours c)
 {
     if (Session["id"] != null && db.users.Find(Session["id"]).type.Equals("admin"))
     {
         cours c1 = db.courses.Find(c.cid);
         db.courses.Remove(c1);
         db.SaveChanges();
         return RedirectToAction("CourseConfiguration");
     }
     return RedirectToAction("signIn", "Home");
 }
Example #4
0
 public ActionResult SaveCourseInfo(cours c)
 {
     if (Session["id"] != null && db.users.Find(Session["id"]).type.Equals("admin"))
     {
         db.Entry(c).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("CourseConfiguration");
     }
     return RedirectToAction("signIn", "Home");
 }
Example #5
0
 public ActionResult EditCourse( cours c)
 {
     if (Session["id"] != null && db.users.Find(Session["id"]).type.Equals("admin"))
     {
         cours c1 = db.courses.Find(c.cid);
         if (c1 == null)
         {
             return HttpNotFound();
         }
         return View(c1);
     }
     return RedirectToAction("signIn", "Home");
 }
Example #6
0
        public ActionResult SaveCourse(cours c)
        {
            if (Session["id"] != null && db.users.Find(Session["id"]).type.Equals("admin"))
            {
                var query = db.courses.Where(x => x.cid.Equals(c.cid));
                string s = null;
                foreach (var a in query)
                {
                    s = s + a.cid + " " + a.name;
                }
                if (s == null)
                {
                    db.courses.Add(c);
                    db.SaveChanges();
                    ViewBag.message = 0;
                }

                return View("CourseConfiguration");
            }
            return RedirectToAction("signIn", "Home");
        }
Example #7
0
        public JsonResult ViewCourseJson(string uid)
        {
            string sid = Request["uid"];
            Response.AppendHeader("Access-Control-Allow-Origin", "null");
            

            var query = (from x in db.students.Where(f => f.sid.Equals(sid))
                         from p in db.courses.Where(g => g.students.Contains(x))
                         select p);
            List<cours> data = new List<cours>();


            foreach (var q in query)
            {
                cours c = new cours();
                c.cid = q.cid;
                c.name = q.name;
                c.creditHours = q.creditHours;
                data.Add(c);
            }

            if (data.Count > 0)
                return Json(data.ToList().ToString(), JsonRequestBehavior.AllowGet);
            else
            {
                ViewBag.ErrorType = "View Courses";
                ViewBag.message = "You are not enrolled in any course";
                return Json(false, JsonRequestBehavior.AllowGet);
            }
        }
Example #8
0
        public ActionResult ViewCourse()
        {
            string sid = Session["id"].ToString();

            var query = (from x in db.students.Where(f => f.sid.Equals(sid))
                         from p in db.courses.Where(g => g.students.Contains(x))
                         select p);
            List<cours> data = new List<cours>();


            foreach (var q in query)
            {
                cours c = new cours();
                c.cid = q.cid;
                c.name = q.name;
                c.creditHours = q.creditHours;
                data.Add(c);
            }

            if (data.Count > 0)
                return View(data);
            else
            {
                ViewBag.ErrorType = "View Courses";
                ViewBag.message = "You are not enrolled in any course";
                return View("ErrorPage");
            }
        }
Example #9
0
        public ActionResult Courses()
        {
            if (Session["id"] != null && (db.users.Find(Session["id"]).type.Equals("Teacher") || db.users.Find(Session["id"]).type.Equals("Student")))
            {
                List<cours> data = new List<cours>();

                if (db.users.Find(Session["id"]).type.Equals("Teacher"))
                {
                    string tid = Session["id"].ToString();

                    var query = (from x in db.teachers.Where(f => f.tid.Equals(tid))
                                 from p in db.courses.Where(g => g.teachers.Contains(x))
                                 select p);


                    foreach (var q in query)
                    {
                        cours c = new cours();
                        c.cid = q.cid;
                        c.name = q.name;
                        c.creditHours = q.creditHours;
                        data.Add(c);

                    }

                }
                else
                {
                    string sid = Session["id"].ToString();

                    var query = (from x in db.students.Where(f => f.sid.Equals(sid))
                                 from p in db.courses.Where(g => g.students.Contains(x))
                                 select p);

                    foreach (var q in query)
                    {
                        cours c = new cours();
                        c.cid = q.cid;
                        c.name = q.name;
                        c.creditHours = q.creditHours;
                        data.Add(c);
                    }

                }

                return View(data);
            }
            else
            {
                ViewBag.message = "Please Login First";
                return View("SignIn");
            }
        }