Example #1
0
        public Option <IMongoCollection <BsonDocument> > GetDistributionResourceCollection(
            DistributionResource resource)
        {
            var mongoCollection = _cache.GetOrAdd(
                resource,
                r => _factory.GetDistributionResourceCollection(r));

            return(mongoCollection);
        }
Example #2
0
        private Option <string> BuildCollectionName(DistributionResource distributionResource)
        {
            var resourceName = GetDistributionResourceName(
                distributionResource.EntityType,
                distributionResource.EntityCode);

            return(resourceName.Match(
                       rn => $"{distributionResource.Culture}{CollectionNameSeparator}{rn}",
                       () => Option <string> .None));
        }
        public async Task <Option <EntityIdentifier> > FindPublishedEntityAsync(SlugReservationKey key)
        {
            var distributionResource = new DistributionResource(key.EntityType, key.EntityCode, key.Culture);
            var collection           = _collectionFactory.GetDistributionResourceCollection(distributionResource);

            var publishedDocument = await collection.MatchAsync(
                async c => await GetPublishedDocumentByIdAsync(c, key.Slug).ConfigureAwait(false),
                () => Option <BsonDocument> .None).ConfigureAwait(false);

            return(publishedDocument.Match(
                       d => Option <EntityIdentifier> .Some(ToEntityIdentifier(d)),
                       () => Option <EntityIdentifier> .None));
        }
Example #4
0
        public Option <IMongoCollection <BsonDocument> > GetDistributionResourceCollection(
            DistributionResource resource)
        {
            var collectionName = BuildCollectionName(resource);

            return(collectionName.Match(
                       cn => Some(
                           _distributionDatabase.GetCollection <BsonDocument>(
                               cn, new MongoCollectionSettings
            {
                GuidRepresentation = GuidRepresentation.CSharpLegacy
            }
                               )
                           ),
                       () => None));
        }