public UserEntity GetUserByDataTypeWithMinLoa(string dataType, string dataValue, DateTime now, LevelOfAssuranceEnum levelOfAssurance, bool fetchCollections = true) { UserDataEntity userDataAlias = null; UserDataTypeEntity userDataTypeAlias = null; LevelOfAssuranceEntity levelOfAssuranceAlias = null; try { var session = GetSession(); var result = session.QueryOver <UserEntity>() .JoinAlias(x => x.UserData, () => userDataAlias) .JoinAlias(() => userDataAlias.UserDataType, () => userDataTypeAlias) .JoinAlias(x => userDataAlias.LevelOfAssurance, () => levelOfAssuranceAlias) .Where(() => (userDataAlias.ActiveTo == null || userDataAlias.ActiveTo > now) && userDataTypeAlias.DataTypeValue == dataType && userDataAlias.Value == dataValue && levelOfAssuranceAlias.Level >= (int)levelOfAssurance) .FutureValue <UserEntity>(); if (fetchCollections) { FetchCollections(session); } return(result.Value); } catch (HibernateException ex) { throw new DatabaseException("Find user by data type with min loa operation failed", ex); } }
public IList <UserDataEntity> FindCurrentVersionOfUserDataWithLoaGreaterThan(string value, string dataTypeValue, LevelOfAssuranceEnum levelOfAssurance, DateTime now) { LevelOfAssuranceEntity levelOfAssuranceAlias = null; try { var session = GetSession(); var query = session.QueryOver <UserDataEntity>() .JoinAlias(x => x.LevelOfAssurance, () => levelOfAssuranceAlias) .Where(x => x.Value == value && (x.ActiveTo == null || x.ActiveTo > now) && levelOfAssuranceAlias.Level > (int)levelOfAssurance); var result = query.JoinQueryOver(x => x.UserDataType) .Where(x => x.DataTypeValue == dataTypeValue) .Future <UserDataEntity>(); FetchCollections(session); return(result.ToList()); } catch (HibernateException ex) { throw new DatabaseException("Find user data by value and type operation failed", ex); } }
public UserDataVersioningProxyTest() { var databaseFactory = new MemoryDatabaseFactory(); var mappings = new AuthorizationMappingProvider().GetMappings(); m_sessionManager = new MockDbFactory(databaseFactory, mappings).CreateSessionManager(true); var mockFactory = new MockRepository(MockBehavior.Loose) { CallBase = true }; m_userDataRepository = mockFactory.Create <UserDataRepository>(m_sessionManager).Object; var userDataComparerMock = mockFactory.Create <UserDataEqualityComparer>(); var userDataStructureConvertorMock = mockFactory.Create <UserDataStructureConvertor>(); m_dateTimeProviderMock = mockFactory.Create <IDateTimeProvider>(); m_dateTimeProviderMock.Setup(x => x.UtcNow).Returns(DateTime.UtcNow); m_dataVersioningProxy = new UserDataVersioningProxy(m_userDataRepository, userDataComparerMock.Object, m_dateTimeProviderMock.Object, userDataStructureConvertorMock.Object); m_testUser = CreateTestUser(Username); m_lowLevelOfAssurance = CreateTestLoa(MediumLoa); m_firstNameDataType = CreateTestDataType(FirstNameDataType); m_lastNameDataType = CreateTestDataType(LastNameDataType); m_userDataSource = CreateTestDataSource(DataSourceEnum.User); }
private LevelOfAssuranceEntity CreateTestLoa(LevelOfAssuranceEnum levelOfAssurance) { var loa = new LevelOfAssuranceEntity() { Level = (int)levelOfAssurance, Name = levelOfAssurance }; var id = (int)m_sessionManager.OpenSession().Save(loa); var loadedLoa = m_sessionManager.OpenSession().Get <LevelOfAssuranceEntity>(id); return(loadedLoa); }
private UserContactEntity GenerateUserContactEntity( DateTime activeFrom, string value, ContactTypeEnum type, UserEntity user, DataSourceEntity dataSource, LevelOfAssuranceEntity loa, DateTime?activeTo = null) { return(new UserContactEntity { ActiveFrom = activeFrom, ActiveTo = activeTo, DataSource = dataSource, LevelOfAssurance = loa, Value = value, Type = type, User = user, }); }
public IList <UserContactEntity> GetActualVersionOfUserContactWithLoaGreaterThan(string contactValue, ContactTypeEnum contactTypeEnum, LevelOfAssuranceEnum levelOfAssurance) { LevelOfAssuranceEntity levelOfAssuranceAlias = null; try { var session = GetSession(); var result = session.QueryOver <UserContactEntity>() .JoinAlias(x => x.LevelOfAssurance, () => levelOfAssuranceAlias) .Where(x => x.Type == contactTypeEnum && x.Value == contactValue && x.ActiveTo == null && levelOfAssuranceAlias.Level > (int)levelOfAssurance) .Future <UserContactEntity>(); FetchCollections(session); return(result.ToList()); } catch (HibernateException ex) { throw new DatabaseException("Find user contact operation failed", ex); } }
public UserEntity GetUserByValidContact(string contactValue, ContactTypeEnum contactType, LevelOfAssuranceEnum minLevelOfAssurance) { LevelOfAssuranceEntity levelOfAssuranceAlias = null; UserContactEntity userContactAlias = null; try { var session = GetSession(); var result = session.QueryOver <UserEntity>() .JoinAlias(x => x.UserContacts, () => userContactAlias) .JoinAlias(() => userContactAlias.LevelOfAssurance, () => levelOfAssuranceAlias) .Where(x => userContactAlias.Type == contactType && userContactAlias.Value == contactValue && userContactAlias.ActiveTo == null && levelOfAssuranceAlias.Level >= (int)minLevelOfAssurance) .FutureValue <UserEntity>(); FetchCollections(session); return(result.Value); } catch (HibernateException ex) { throw new DatabaseException("Find user by contact operation failed", ex); } }
private void SetTreeStructureUserDataVerificationStatus(UserDataEntity userData, UserEntity verifier, LevelOfAssuranceEntity levelOfAssurance) { userData.VerifiedBy = verifier; userData.LevelOfAssurance = levelOfAssurance; if (userData.ChildrenUserData != null) { foreach (var childrenUserData in userData.ChildrenUserData) { SetTreeStructureUserDataVerificationStatus(childrenUserData, verifier, levelOfAssurance); } } }