public ActionResult AddExamClass(mst_exam_class mst)
        {
            try
            {
                mst_exam_classMain main = new mst_exam_classMain();

                main.AddExamClass(mst);

                return(RedirectToAction("AllExamClassList"));
            }
            catch
            {
                mst_classMain mstClass   = new mst_classMain();
                mst_examMain  mstsubject = new mst_examMain();

                mst_sessionMain sess = new mst_sessionMain();

                var class_list = mstClass.AllClassList(sess.findFinal_Session());

                var exam_list = mstsubject.AllExamList();

                IEnumerable <SelectListItem> list  = new SelectList(class_list, "class_id", "class_name");
                IEnumerable <SelectListItem> list1 = new SelectList(exam_list, "exam_id", "exam_name");


                ViewData["class_id"] = list;
                ViewData["exam_id"]  = list1;

                ModelState.AddModelError(String.Empty, "Class Already Assigned");

                return(View(mst));
            }
        }
        public ActionResult EditExam(mst_exam mst)
        {
            mst_examMain stdMain = new mst_examMain();

            stdMain.EditExam(mst);

            return(RedirectToAction("AllExamList"));
        }
        public ActionResult AddExam(mst_exam mst)
        {
            mst_examMain mstMain = new mst_examMain();

            mstMain.AddExam(mst);

            return(RedirectToAction("AllExamList"));
        }
        public ActionResult studentList(mst_exam_marks mst)
        {
            mst_subjectMain       subjectMain = new mst_subjectMain();
            mst_subject           subject     = new mst_subject();
            List <mst_exam_marks> list        = new List <mst_exam_marks>();

            mst_examMain examMain = new mst_examMain();
            mst_exam     exam     = new mst_exam();


            mst_exam_marksMain mstMain = new mst_exam_marksMain();

            //IEnumerable<mst_exam_marks> marks = mstMain.find_marks(mst.exam_id, mst.subject_id, mst.class_id, mst.section_id);

            //if (marks.Count() > 0)
            //{
            var student_list = mstMain.student_list_for_marks_update(mst.subject_id, mst.class_id, mst.section_id, mst.exam_id);

            exam = examMain.FindExam(mst.exam_id);

            ViewData["MaxMarks"] = exam.max_no;

            subject = subjectMain.FindSubject(mst.subject_id);

            foreach (var i in student_list)
            {
                list.Add(new mst_exam_marks {
                    present = i.present, marks = i.marks, class_id = i.class_id, exam_id = mst.exam_id, exam_name = exam.exam_name, marks_assigned_user_id = mst.marks_assigned_user_id, section_id = i.section_id, roll_no = i.roll_no, sr_num = i.sr_num, std_name = i.std_name, subject_id = mst.subject_id, subject_name = subject.subject_name, user_id = Int32.Parse(Request.Cookies["loginUserId"].Value.ToString())
                });
            }
            //}
            //else
            //{
            //    var student_list = mstMain.student_list_for_marks(mst.class_id, mst.section_id);
            //    exam = examMain.FindExam(mst.exam_id);

            //    ViewData["MaxMarks"] = exam.max_no;

            //    subject = subjectMain.FindSubject(mst.subject_id);

            //    foreach (var i in student_list)
            //    {
            //        list.Add(new mst_exam_marks { class_id = i.class_id, exam_id = mst.exam_id, exam_name = exam.exam_name, marks_assigned_user_id = mst.marks_assigned_user_id, section_id = i.section_id, roll_no = i.roll_no, sr_num = i.sr_num, std_name = i.std_name, subject_id = mst.subject_id, subject_name = subject.subject_name, user_id = Int32.Parse(Request.Cookies["loginUserId"].Value.ToString()), present = true });
            //    }
            //}



            return(View(list));
        }
        public ActionResult DeleteExam(int id, FormCollection collection)
        {
            try
            {
                mst_examMain stdMain = new mst_examMain();

                stdMain.DeleteExam(id);

                return(RedirectToAction("AllExamList"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(String.Empty, "Exam is assigned cannot delete");

                return(RedirectToAction("AllExamList"));
            }
        }
        public ActionResult AddExamClass()
        {
            mst_classMain mstClass   = new mst_classMain();
            mst_examMain  mstsubject = new mst_examMain();

            mst_sessionMain sess = new mst_sessionMain();

            var class_list = mstClass.AllClassList(sess.findFinal_Session());

            var exam_list = mstsubject.AllExamList();

            IEnumerable <SelectListItem> list  = new SelectList(class_list, "class_id", "class_name");
            IEnumerable <SelectListItem> list1 = new SelectList(exam_list, "exam_id", "exam_name");


            ViewData["class_id"] = list;
            ViewData["exam_id"]  = list1;

            return(View());
        }
        public ActionResult DeleteExam(int id)
        {
            mst_examMain stdMain = new mst_examMain();

            return(View(stdMain.FindExam(id)));
        }
        public ActionResult EditExam(int?id)
        {
            mst_examMain stdMain = new mst_examMain();

            return(View(stdMain.FindExam(id)));
        }
        public ActionResult AllExamList()
        {
            mst_examMain stdMain = new mst_examMain();

            return(View(stdMain.AllExamList()));
        }