public TagsController(EventStoreService eventStore, CacheDatabaseManager db, InMemoryCache cache)
 {
     _eventStore      = eventStore;
     _db              = db;
     _entityIndex     = cache.Index <EntityIndex>();
     _mediaIndex      = cache.Index <MediaIndex>();
     _tagIndex        = cache.Index <TagIndex>();
     _referencesIndex = cache.Index <ReferencesIndex>();
 }
 public RoutesController(EventStoreService eventStore, CacheDatabaseManager db, IEnumerable <IDomainIndex> indices)
 {
     _eventStore      = eventStore;
     _db              = db;
     _mediaIndex      = indices.OfType <MediaIndex>().First();
     _entityIndex     = indices.OfType <EntityIndex>().First();
     _referencesIndex = indices.OfType <ReferencesIndex>().First();
     _ratingIndex     = indices.OfType <RatingIndex>().First();
 }
 public MediaController(EventStoreService eventStore, CacheDatabaseManager db, InMemoryCache cache,
                        IOptions <UploadFilesConfig> uploadConfig, IOptions <EndpointConfig> endpointConfig,
                        ILogger <MediaController> logger)
 {
     _logger          = logger;
     _eventStore      = eventStore;
     _db              = db;
     _entityIndex     = cache.Index <EntityIndex>();
     _mediaIndex      = cache.Index <MediaIndex>();
     _referencesIndex = cache.Index <ReferencesIndex>();
     _uploadConfig    = uploadConfig.Value;
     _endpointConfig  = endpointConfig.Value;
 }
Exemple #4
0
 public ExhibitPagesController(
     IOptions <ExhibitPagesConfig> exhibitPagesConfig,
     EventStoreService eventStore,
     CacheDatabaseManager db,
     InMemoryCache cache)
 {
     _exhibitPagesConfig = exhibitPagesConfig;
     _eventStore         = eventStore;
     _db               = db;
     _mediaIndex       = cache.Index <MediaIndex>();
     _entityIndex      = cache.Index <EntityIndex>();
     _referencesIndex  = cache.Index <ReferencesIndex>();
     _exhibitPageIndex = cache.Index <ExhibitPageIndex>();
 }
Exemple #5
0
        /// <summary>
        /// Obtains reference information for a resource.
        /// </summary>
        /// <returns>
        /// "200 Ok" with reference info if successful.
        /// "404 Not Found" if no resource with the specified type and ID exists.
        /// </returns>
        public static IActionResult GetReferenceInfo(ResourceType type, int id, EntityIndex entityIndex, ReferencesIndex referencesIndex)
        {
            if (!entityIndex.Exists(type, id))
            {
                return(new NotFoundResult());
            }

            return(new OkObjectResult(new ReferenceInfoResult
            {
                OutgoingReferences = TransformToResult(referencesIndex.ReferencesOf(type, id)),
                IncomingReferences = TransformToResult(referencesIndex.ReferencesTo(type, id))
            }));

            IReadOnlyCollection <ReferenceInfoResult.ReferenceInfo> TransformToResult(IEnumerable <EntityId> refs)
            {
                return(refs
                       .GroupBy(entry => entry.Type)
                       .Select(group => new ReferenceInfoResult.ReferenceInfo
                {
                    Type = group.Key.Name,
                    Ids = group.Select(e => e.Id).OrderBy(i => i).ToList()
                })
                       .OrderBy(group => group.Type)
                       .ToList());
            }
        }