예제 #1
0
        public async Task JournalTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage     = new CourseStorage(connection, transaction);
            groupStorage      = new GroupStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);
            userStorage       = new UserStorage(connection, transaction);
            lessonStorage     = new LessonStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();
                await TestUpdate();

                foreach (Journal journalToDelete in listJournal)
                {
                    await TestEntityDelete(journalToDelete);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                transaction.Rollback();
            }
        }
예제 #2
0
        public void TimeTableTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            groupStorage  = new GroupStorage(connection, transaction);
            lessonStorage = new LessonStorage(connection, transaction);
            courseStorage = new CourseStorage(connection, transaction);

            try
            {
                Setup();
                TestSelects();
                TestUpdate();

                foreach (TimeTable timeTableToDelete in listTimetable)
                {
                    TestEntityDelete(timeTableToDelete);
                }

                ClearAllMocks();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
예제 #3
0
        public void StudentGroupTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage     = new CourseStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);
            userStorage       = new UserStorage(connection, transaction);
            groupStorage      = new GroupStorage(connection, transaction);

            try
            {
                Setup();
                TestSelects();
                foreach (StudentGroup studentGroupToDelete in listStudentGroup)
                {
                    TestEntityDelete(studentGroupToDelete);
                }
                ClearTest();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
예제 #4
0
        public async Task TeacherGroupTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage     = new CourseStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);
            userStorage       = new UserStorage(connection, transaction);
            groupStorage      = new GroupStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();

                foreach (TeacherGroup teacherGroupToDelete in listTeacherGroup)
                {
                    await TestEntityDelete(teacherGroupToDelete);
                }

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
예제 #5
0
        public async Task LessonTopicTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage = new CourseStorage(connection, transaction);
            groupStorage  = new GroupStorage(connection, transaction);
            lessonStorage = new LessonStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();

                foreach (LessonTopic lessonTopicToDelete in listLessonTopic)
                {
                    await TestEntityDelete(lessonTopicToDelete);
                }
            }
            catch
            {
                throw new Exception();
            }
            finally
            {
                transaction.Rollback();
            }
        }
예제 #6
0
        public LessonController(IConfiguration Configuration)
        {
            string dbCon = Configuration.GetConnectionString("DefaultConnection");

            lessonStorage = new LessonStorage(dbCon);
            groupStorage  = new GroupStorage(dbCon);
            courseStorage = new CourseStorage(dbCon);
        }
예제 #7
0
        public UserController(IConfiguration Configuration)
        {
            string dbCon = Configuration.GetConnectionString("DefaultConnection");

            userStorage            = new UserStorage(dbCon);
            groupStorage           = new GroupStorage(dbCon);
            userAttestationStorage = new UserAttestationStorage(dbCon);
        }
예제 #8
0
 public void AddGroup(string name)
 {
     if (!Context.PersonId.HasValue)
     {
         throw new UnassignedUserException();
     }
     BaseSecurity.IsDistrictAdmin(Context); // only admin can create group ... think do we need this for demo
     GroupStorage.Add(new Group {
         Name = name, OwnerRef = Context.PersonId.Value
     });
 }
예제 #9
0
        public Group EditGroup(int groupId, string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ChalkableException("Invalid name param. Name parameter is empty");
            }
            var group = GroupStorage.GetById(groupId);

            EnsureInGroupModifyPermission(group);
            group.Name = name;
            GroupStorage.Update(group);
            return(group);
        }
예제 #10
0
 public GroupService(GroupStorage groupStorage, GroupService groupService)
 {
     _groupStorage = groupStorage;
     _groupService = groupService;
 }
예제 #11
0
 public void UnassignStudentsFromGroup(int groupId, IList <int> studentIds)
 {
     DemandStudentIdsParam(studentIds);
     EnsureInGroupModifyPermission(GroupStorage.GetById(groupId));
     StudentGroupStorage.Delete(BuildStudentGroups(groupId, studentIds));
 }
예제 #12
0
 public void DeleteGroup(int groupId)
 {
     EnsureInGroupModifyPermission(GroupStorage.GetById(groupId));
     GroupStorage.Delete(groupId);
 }
예제 #13
0
        public GroupController(IConfiguration Configuration)
        {
            string dbCon = Configuration.GetConnectionString("DefaultConnection");

            groupStorage = new GroupStorage(dbCon);
        }