public void TestCoreTestsAccess(int testId) { bool hasAccess = CurrentUser.UserRole == TestorUserRole.Administrator; if (CurrentUser.UserRole == TestorUserRole.Teacher || CurrentUser.UserRole == TestorUserRole.Laboratorian) { using (DataClassesTestorCoreDataContext dataContext = new DataClassesTestorCoreDataContext(TestorSecurityProvider.ConnectionString)) { int?uid = dataContext.GetTestOwner(testId); if (uid.HasValue && CurrentUser.UserId == uid) { hasAccess = true; } } } if (!hasAccess) { ThrowAccessFaultException(); } }