Exemplo n.º 1
0
        public ActionResult Save(List <string> chkApprove, string qual)
        {
            db_tafebuddyEntities _db  = new db_tafebuddyEntities();
            List <string>        list = chkApprove as List <string>;

            parchment_approved pa = new parchment_approved()
            {
                StudentID   = list[0],
                LecturerID  = list[1],
                QualCode    = qual,
                ApproveDate = DateTime.Now
            };

            List <parchment_approved> paList = _db.parchment_approved.ToList();

            var students = _db.students.ToList();

            if (paList.Any(a => a.StudentID.Equals(pa.StudentID) && a.QualCode.Equals(pa.QualCode)))
            {
                ViewBag.AddParchment = "false";
                return(RedirectToAction("SelectQual", "SRVLogin", new { studentId = list[0], qual = qual }));
            }
            else
            {
                // add to the db.

                _db.Entry(pa).State = EntityState.Added;
                _db.SaveChanges();
                ViewBag.AddParchment = "true";
                return(RedirectToAction("SelectQual", "SRVLogin", new { studentId = list[0], qual = qual, save = 1 }));
            }
        }
Exemplo n.º 2
0
        //private db_tafebuddyEntities db = new db_tafebuddyEntities();

        public static List <string> GetSubjectsByQualification(db_tafebuddyEntities db, string qual)
        {
            List <string> result = new List <string>();

            List <subject_qualification> subjects = db.subject_qualification.Where(a => a.QualCode.Equals(qual)).ToList();
            List <string> subCodes = new List <string>();

            subjects.ForEach(a => subCodes.Add(a.SubjectCode));
            return(subCodes);
        }
Exemplo n.º 3
0
        public static List <student_grade> GetStudentGradeListByQual(db_tafebuddyEntities db, string studentId, string qual)
        {
            List <student_grade> listGrades = new List <student_grade>();

            student_studyplan ssp = db.student_studyplan.Where(a => a.QualCode.ToUpper().Equals(qual.ToUpper())).FirstOrDefault();

            Dictionary <string, string> subjects = new Dictionary <string, string>();

            var grades = db.student_grade.Where(a => a.StudentID.Equals(studentId)).ToList();

            grades.ForEach(a => subjects.Add(a.CRN, a.crn_detail.SubjectCode));

            // all the subjects according to the qualification
            List <string> subCodes = SRVReusltFunc.GetSubjectsByQualification(db, qual);


            foreach (var item in subCodes)
            {
                bool found = false;
                foreach (var i in subjects)
                {
                    if (i.Value.ToUpper().Equals(item.ToUpper()))
                    {
                        student_grade grade = db.student_grade.Where(a => a.crn_detail.CRN.ToUpper().Equals(i.Key.ToUpper()) && a.StudentID.Equals(studentId)).FirstOrDefault() as student_grade;
                        listGrades.Add(grade);
                        found = true;
                    }
                }
                if (!found)
                {
                    crn_detail        cd = db.crn_detail.Where(a => a.SubjectCode.ToUpper().Equals(item.ToUpper())).FirstOrDefault();
                    student_studyplan ss = db.student_studyplan.Where(a => a.StudentID.Equals(studentId) && a.QualCode.Equals(qual)).FirstOrDefault();
                    if (cd != null)
                    {
                        listGrades.Add(new student_grade()
                        {
                            StudentID    = studentId,
                            CRN          = cd.CRN,
                            TafeCompCode = cd.TafeCompCode,
                            TermCode     = ss.TermCodeStart,
                            TermYear     = ss.TermYearStart,
                            Grade        = "NS",
                            GradeDate    = null,
                            crn_detail   = cd,
                            student      = grades[0].student
                        });
                    }
                }
            }

            return(listGrades);
        }