Example #1
0
        public ActionResult PostNewMark(MarksVM post)
        {
            using (var ctx = new CSEntities())
            {
                ctx.AddNewMark(post.Course.FirstOrDefault(), post.StudentID, post.Mark, post.Date.FirstOrDefault().ToString(), post.Teacher);

                return(RedirectToAction("Marks", "Home"));
            }
        }
Example #2
0
        public ActionResult Marks()
        {
            MarksVM model = new MarksVM();

            using (var ctx = new CSEntities())
            {
                int UserIDint = Int32.Parse(Session["ID"].ToString());

                var UserRole = from p in ctx.People where p.ID == UserIDint
                               select p.RoleID;

                string UserIDstring = Session["ID"].ToString();

                if (UserRole.FirstOrDefault().ToString() == "3" || UserRole.FirstOrDefault().ToString() == "4")
                {
                    model.MarksByUser = ctx.MarksByUser(UserIDint).ToList();
                }
                else
                {
                    model.MarksList = (from t in ctx.MarkLists select t).ToList();
                }

                model.Teacher   = Session["LNAME"].ToString();
                model.TeacherID = Int32.Parse(Session["ID"].ToString());



                model.Course = (from c in ctx.Courses
                                join ct in ctx.CourseTeachers on c.ID equals ct.CourseID
                                join t in ctx.Teachers on ct.TeacherID equals t.ID
                                join p in ctx.People on t.PersonID equals p.ID
                                where p.ID == model.TeacherID && c.Closed == false
                                select c.Name).ToList();

                model.Date = (from cs in ctx.ClassSchedules
                              join t in ctx.Teachers on cs.TeacherID equals t.ID
                              join p in ctx.People on t.PersonID equals p.ID
                              where p.ID == model.TeacherID
                              select cs.StartTime).ToList();
            }
            return(View(model));
        }