public GetUserByNormalizedEmailQueryAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(AuthorizationConnectionClass.GetConnectionName()))
        {
            var context = (DomainFramework.DataAccess.RepositoryContext)RepositoryContext;

            UserQueryRepository.Register(context);

            RoleQueryRepository.Register(context);

            User_UserLogins_QueryRepository.Register(context);

            GetUserLoginsOperation = new GetCollectionLinkedValueObjectQueryOperation <User, UserLogin, User_UserLogins_QueryRepository.RepositoryKey>
            {
                GetLinkedValueObjects      = (repository, entity, user) => ((User_UserLogins_QueryRepository)repository).GetAll(RootEntity.Id).ToList(),
                GetLinkedValueObjectsAsync = async(repository, entity, user) =>
                {
                    var items = await((User_UserLogins_QueryRepository)repository).GetAllAsync(RootEntity.Id);

                    return(items.ToList());
                }
            };

            QueryOperations.Enqueue(GetUserLoginsOperation);

            GetAllRolesLinkedAggregateQueryOperation = new GetAllLinkedAggregateQueryCollectionOperation <int, Role, RoleOutputDto>
            {
                GetAllLinkedEntities      = (repository, entity, user) => ((RoleQueryRepository)repository).GetAllRolesForUser(RootEntity.Id).ToList(),
                GetAllLinkedEntitiesAsync = async(repository, entity, user) =>
                {
                    var entities = await((RoleQueryRepository)repository).GetAllRolesForUserAsync(RootEntity.Id);

                    return(entities.ToList());
                },
                CreateLinkedQueryAggregate = entity =>
                {
                    if (entity is Role)
                    {
                        return(new GetRoleByIdQueryAggregate());
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            };

            QueryOperations.Enqueue(GetAllRolesLinkedAggregateQueryOperation);
        }
Example #2
0
        public GetUserByNormalizedEmailQueryAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(UserWithUserLoginsConnectionClass.GetConnectionName()))
        {
            var context = (DomainFramework.DataAccess.RepositoryContext)RepositoryContext;

            UserQueryRepository.Register(context);

            User_UserLogins_QueryRepository.Register(context);

            GetUserLoginsOperation = new GetCollectionLinkedValueObjectQueryOperation <User, UserLogin, User_UserLogins_QueryRepository.RepositoryKey>
            {
                GetLinkedValueObjects      = (repository, entity, user) => ((User_UserLogins_QueryRepository)repository).GetAll(RootEntity.Id).ToList(),
                GetLinkedValueObjectsAsync = async(repository, entity, user) =>
                {
                    var items = await((User_UserLogins_QueryRepository)repository).GetAllAsync(RootEntity.Id);

                    return(items.ToList());
                }
            };

            QueryOperations.Enqueue(GetUserLoginsOperation);
        }