Exemplo n.º 1
0
        /// <summary>
        /// Gets a value indicating whether the specified catalog entry already exists.
        /// </summary>
        /// <param name="entry">The catalog entry.</param>
        /// <returns><c>true</c> if the catalog entry exists. Otherwise <c>false.</c></returns>
        public async Task <bool> CatalogEntryExists(CatalogEntry entry)
        {
            using (IDocumentContextScope scope = this.dataContextScopeFactory.CreateDocumentContextScope(this.connectionStrings.DataAggregationDB))
            {
                IFileDocumentRepository repository = scope.GetRepository <IFileDocumentRepository>();

                return((await repository.GetAsync(entry.ID)) != null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the catalog entry by the initial instance set.
        /// </summary>
        /// <param name="entry">The initial catalog entry set.</param>
        /// <returns>The instance of <see cref="CatalogEntry"/> type.</returns>
        public async Task <CatalogEntry> GetCatalogEntry(CatalogEntry entry)
        {
            FileDocument    fileDocument    = null;
            CatalogDocument catalogDocument = null;

            using (IDocumentContextScope scope = this.dataContextScopeFactory.CreateDocumentContextScope(this.connectionStrings.DataAggregationDB))
            {
                IFileDocumentRepository fileRepository = scope.GetRepository <IFileDocumentRepository>();
                fileDocument = await fileRepository.GetAsync(entry.ID);

                if ((entry.Catalog?.ID).HasValue)
                {
                    ICatalogDocumentRepository catalogRepository = scope.GetRepository <ICatalogDocumentRepository>();
                    catalogDocument = await catalogRepository.GetAsync(entry.Catalog.ID);
                }
            }

            entry = await this.mapper.MapAsync(fileDocument, entry);

            entry.Catalog = await this.mapper.MapAsync(catalogDocument, entry.Catalog);

            return(entry);
        }