public IAsyncEnumerable <CharacterGuildIdentityViewModel> AsyncEnumerateIdentities(
            Optional <bool> isDeleted = default)
        {
            CharactersLogMessages.CharacterGuildIdentitiesEnumerating(_logger, isDeleted);

            var query = _context.Set <CharacterGuildVersionEntity>()
                        .AsQueryable()
                        .Where(x => x.NextVersionId == null);

            RepositoryLogMessages.QueryInitializing(_logger, query);

            if (isDeleted.IsSpecified)
            {
                RepositoryLogMessages.QueryAddingWhereClause(_logger, nameof(isDeleted));
                query = query.Where(x => x.IsDeleted == isDeleted.Value);
            }

            RepositoryLogMessages.QueryTerminating(_logger);
            var result = query
                         .Select(CharacterGuildIdentityViewModel.FromVersionEntityProjection)
                         .AsAsyncEnumerable();

            RepositoryLogMessages.QueryBuilt(_logger);
            return(result);
        }
        public Task <bool> AnyVersionsAsync(
            Optional <long> guildId = default,
            Optional <IEnumerable <long> > excludedGuildIds = default,
            Optional <string> name              = default,
            Optional <bool> isDeleted           = default,
            Optional <bool> isLatestVersion     = default,
            CancellationToken cancellationToken = default)
        {
            CharactersLogMessages.CharacterGuildVersionsEnumeratingAny(_logger, guildId, excludedGuildIds, name, isDeleted, isLatestVersion);

            var query = _context.Set <CharacterGuildVersionEntity>()
                        .AsQueryable();

            RepositoryLogMessages.QueryInitializing(_logger, query);

            if (guildId.IsSpecified)
            {
                RepositoryLogMessages.QueryAddingWhereClause(_logger, nameof(guildId));
                query = query.Where(x => x.GuildId == guildId.Value);
            }

            if (excludedGuildIds.IsSpecified)
            {
                RepositoryLogMessages.QueryAddingWhereClause(_logger, nameof(excludedGuildIds));
                query = query.Where(x => !excludedGuildIds.Value.Contains(x.GuildId));
            }

            if (name.IsSpecified)
            {
                RepositoryLogMessages.QueryAddingWhereClause(_logger, nameof(name));
                query = query.Where(x => x.Name == name.Value);
            }

            if (isDeleted.IsSpecified)
            {
                RepositoryLogMessages.QueryAddingWhereClause(_logger, nameof(isDeleted));
                query = query.Where(x => x.IsDeleted == isDeleted.Value);
            }

            if (isLatestVersion.IsSpecified)
            {
                RepositoryLogMessages.QueryAddingWhereClause(_logger, nameof(isLatestVersion));
                query = isLatestVersion.Value
                    ? query.Where(x => x.NextVersionId == null)
                    : query.Where(x => x.NextVersionId != null);
            }

            RepositoryLogMessages.QueryTerminating(_logger);
            var result = query.AnyAsync(cancellationToken);

            RepositoryLogMessages.QueryExecuting(_logger);
            return(result);
        }
        public async Task <long> CreateAsync(
            string name,
            long actionId,
            CancellationToken cancellationToken)
        {
            CharactersLogMessages.CharacterGuildCreating(_logger, name, actionId);

            using var transactionScope = _transactionScopeFactory.CreateScope();
            TransactionsLogMessages.TransactionScopeCreated(_logger);

            var guild = new CharacterGuildEntity(
                id: default);
예제 #4
0
        public async Task <long> CreateAsync(
            ulong ownerId,
            string name,
            long divisionId,
            int experiencePoints,
            int goldAmount,
            int insanityValue,
            long actionId,
            CancellationToken cancellationToken)
        {
            CharactersLogMessages.CharacterCreating(_logger, ownerId, name, divisionId, experiencePoints, goldAmount, insanityValue, actionId);

            using var transactionScope = _transactionScopeFactory.CreateScope();
            TransactionsLogMessages.TransactionScopeCreated(_logger);

            var character = new CharacterEntity(
                id:         default,
예제 #5
0
        public async Task <OperationResult> MergeDefinitionAsync(
            int level,
            int experienceThreshold,
            bool isDeleted,
            long actionId,
            CancellationToken cancellationToken)
        {
            CharactersLogMessages.CharacterLevelDefinitionMerging(_logger, level, experienceThreshold, isDeleted, actionId);

            using var transactionScope = _transactionScopeFactory.CreateScope();
            TransactionsLogMessages.TransactionScopeCreated(_logger);

            var currentVersion = await _context.Set <CharacterLevelDefinitionVersionEntity>()
                                 .AsQueryable()
                                 .Where(x => x.Level == level)
                                 .Where(x => x.NextVersionId == null)
                                 .FirstOrDefaultAsync(cancellationToken);

            var newVersion = new CharacterLevelDefinitionVersionEntity(
                id:                     default,
예제 #6
0
        public Task <bool> AnyDefinitionsAsync(
            Optional <int> level = default,
            Optional <int> experienceThreshold  = default,
            Optional <bool> isDeleted           = default,
            CancellationToken cancellationToken = default)
        {
            CharactersLogMessages.CharacterLevelDefinitionsEnumeratingAny(_logger, level, experienceThreshold, isDeleted);

            var query = _context.Set <CharacterLevelDefinitionVersionEntity>()
                        .AsQueryable()
                        .Where(x => x.NextVersionId == null);

            RepositoryLogMessages.QueryInitializing(_logger, query);

            if (level.IsSpecified)
            {
                RepositoryLogMessages.QueryAddingWhereClause(_logger, nameof(level));
                query = query.Where(cld => cld.Level == level.Value);
            }

            if (experienceThreshold.IsSpecified)
            {
                RepositoryLogMessages.QueryAddingWhereClause(_logger, nameof(experienceThreshold));
                query = query.Where(cld => cld.ExperienceThreshold == experienceThreshold.Value);
            }

            if (isDeleted.IsSpecified)
            {
                RepositoryLogMessages.QueryAddingWhereClause(_logger, nameof(isDeleted));
                query = query.Where(cld => cld.IsDeleted == isDeleted.Value);
            }

            RepositoryLogMessages.QueryTerminating(_logger);
            var result = query.AnyAsync(cancellationToken);

            RepositoryLogMessages.QueryExecuting(_logger);
            return(result);
        }