Esempio n. 1
0
        public void TestDaoSessionExamsCRUD()
        {
            DaoSessionExams daoExams = new DaoSessionExams(connectionString);

            var allExams = daoExams.GetAllRecords();
            int count    = allExams.Count;

            SessionExam exam = new SessionExam(2, 8, "exam", 1, new DateTime(2020, 12, 21));

            daoExams.Create(exam);

            allExams = daoExams.GetAllRecords();
            Assert.AreEqual(count + 1, allExams.Count);

            exam.ID = allExams.Last().ID;

            exam.GroupID   = 3;
            exam.SubjectID = 3;

            daoExams.Update(exam);

            SessionExam updExam = daoExams.GetById(exam.ID);

            Assert.AreEqual(exam, updExam);

            daoExams.Delete(exam);
            Assert.AreEqual(count, daoExams.GetAllRecords().Count);
        }
Esempio n. 2
0
        /// <summary>
        /// Get student session results
        /// </summary>
        /// <param name="sessionNumber"> Session number</param>
        /// <param name="groupName"> Group name</param>
        /// <returns></returns>
        public List <ReportSessionStudent> GetStudentsResults(int sessionNumber, string groupName)
        {
            var students = daoStudent.GetAllRecords();
            var subjects = daoSubject.GetAllRecords();
            var groups   = daoGroup.GetAllRecords();
            var exams    = daoExams.GetAllRecords();
            var results  = daoResults.GetAllRecords();

            int id = groups.Where(x => x.Name == groupName).Select(x => x.ID).First();

            List <ReportSessionStudent> studs = new List <ReportSessionStudent>();

            var allResults = from result in results
                             join exam in exams on result.ExamID equals exam.ID
                             join sbj in subjects on exam.SubjectID equals sbj.ID
                             join grp in groups on exam.GroupID equals grp.ID
                             join student in students on result.StudentID equals student.ID
                             where exam.SessionNumber == sessionNumber & exam.GroupID == id
                             select new
            {
                LastName    = student.LastName,
                FirstName   = student.FirstName,
                MiddleName  = student.MiddleName,
                GroupName   = grp.Name,
                SubjectName = sbj.Name,
                ExamType    = exam.Type,
                Grade       = result.Grade
            };

            foreach (var st in allResults.OrderBy(s => s.Grade).ThenBy(s => s.LastName))
            {
                studs.Add(new ReportSessionStudent()
                {
                    LastName    = st.LastName,
                    FirstName   = st.FirstName,
                    MiddleName  = st.MiddleName,
                    GroupName   = st.GroupName,
                    SubjectName = st.SubjectName,
                    ExamType    = st.ExamType,
                    Grade       = st.Grade
                });
            }

            return(studs);
        }