Пример #1
0
        public void TestDaoGroupsCRUD()
        {
            DaoGroups daoGroups = new DaoGroups(connectionString);

            var allGroups = daoGroups.GetAllRecords();
            int count     = allGroups.Count;

            Group group = new Group("ITP-21");

            daoGroups.Create(group);

            allGroups = daoGroups.GetAllRecords();
            Assert.AreEqual(count + 1, allGroups.Count);

            group.ID = allGroups.Last().ID;

            group.Name = "PVP-21";

            daoGroups.Update(group);

            Group updGroup = daoGroups.GetById(group.ID);

            Assert.AreEqual(group, updGroup);

            daoGroups.Delete(group);
            Assert.AreEqual(count, daoGroups.GetAllRecords().Count);
        }
Пример #2
0
        public void TestDaoGroupsCRUD()
        {
            DaoGroups daoGroups = daoFactory.GetDaoGroups();

            Group group = new Group("TPT-22", 2);

            var allGroups = daoGroups.GetAllRecords();
            int count     = allGroups.Count;

            daoGroups.Create(group);

            allGroups = daoGroups.GetAllRecords();
            Assert.AreEqual(count + 1, allGroups.Count);

            group.ID = allGroups.Last().ID;

            group.Name = "PVP-21";

            daoGroups.Update(group);

            Group updGroup = daoGroups.GetById(group.ID);

            Assert.AreEqual(group, updGroup);

            daoGroups.Delete(group);
            Assert.AreEqual(count, daoGroups.GetAllRecords().Count);
        }
Пример #3
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)
            {
                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);
        }