Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SourcesModule" /> class.
        /// </summary>
        public SourcesModule(
            ISourcesRepository repository,
            IUriTemplateExpander expander,
            IIriTemplateFactory templateFactory,
            IModelTemplateProvider modelTemplateProvider,
            ISupportedClassMetaProvider supportedClass)
            : base(modelTemplateProvider)
        {
            this.expander        = expander;
            this.expander        = expander;
            this.templateFactory = templateFactory;
            this.supportedClass  = supportedClass;

            this.Get <Brochure>(async r => await this.GetSingle(repository.GetBrochure));
            this.Get <Book>(async r => await this.GetSingle(repository.GetBook));
            this.Get <Magazine>(async r => await this.GetSingle(repository.GetMagazine));
            this.Get <Collection <Issue> >(async r => await this.GetSingle(repository.GetMagazineIssues, new Collection <Issue>()));
            this.Get <Issue>(async r => await this.GetSingle(repository.GetIssue));

            using (this.Templates)
            {
                this.Get <Collection <Brochure> >(async r => await this.GetPage <Brochure, BrochureFilters>((int?)r.page, repository.GetBrochures));
                this.Get <Collection <Magazine> >(async r => await this.GetPage <Magazine, MagazineFilters>((int?)r.page, repository.GetMagazines));
                this.Get <Collection <Book> >(async r => await this.GetPage <Book, BookFilters>((int?)r.page, repository.GetBooks));
            }
        }
Ejemplo n.º 2
0
        public ExtractPagesTests()
        {
            this.persistence      = Substitute.For <ISourcesPersistence>();
            this.sourceRepository = Substitute.For <ISourcesRepository>();
            this.context          = Substitute.For <ISourceContext>();
            this.imageService     = new FakeImageService();
            var matcher = Substitute.For <IUriTemplateMatcher>();

            this.httpMessageHandler = new MockHttpMessageHandler();

            matcher.Match <Brochure>(Arg.Any <Uri>())
            .Returns(new UriTemplateMatches(new Dictionary <string, object>
            {
                { "id", 10 },
            }));

            this.sourceRepository.GetBrochure(Arg.Any <Uri>())
            .Returns(Task.FromResult(new Brochure
            {
                Id = new Uri(SourceId),
            }));

            this.functions = new ExtractPages(
                this.sourceRepository,
                this.imageService,
                matcher,
                this.context,
                this.persistence);

            this.functions.Client = this.httpMessageHandler.ToHttpClient();
        }
Ejemplo n.º 3
0
 public FeedUpdateAgent(
     ISourcesRepository sources,
     ILogger <FeedUpdateAgent> logger)
 {
     _sources = sources;
     _logger  = logger;
     _cancellationTokenSource = new CancellationTokenSource();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Create new instance of <see cref="DataSeriesRepository"/>
 /// </summary>
 /// <param name="dbType">The type of the database (SQLite, SQLServer, ...)</param>
 /// <param name="connectionString">The connection string</param>
 public DataSeriesRepository(DatabaseTypes dbType, string connectionString) : base(dbType, connectionString)
 {
     _sitesRepository                = new SitesRepository(dbType, connectionString);
     _variablesRepository            = new VariablesRepository(dbType, connectionString);
     _methodsRepository              = new MethodsRepository(dbType, connectionString);
     _qualityControlLevelsRepository = new QualityControlLevelsRepository(dbType, connectionString);
     _sourcesRepository              = new SourcesRepository(dbType, connectionString);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Create new instance of <see cref="DataSeriesRepository"/>
 /// </summary>
 /// <param name="db">The DbOperations object for handling the database</param>
 public DataSeriesRepository(IHydroDbOperations db)
     : base(db)
 {
     _sitesRepository                = new SitesRepository(db);
     _variablesRepository            = new VariablesRepository(db);
     _methodsRepository              = new MethodsRepository(db);
     _qualityControlLevelsRepository = new QualityControlLevelsRepository(db);
     _sourcesRepository              = new SourcesRepository(db);
 }
Ejemplo n.º 6
0
 public FeedCollectionsController(
     IRepository <FeedCollection> collections,
     ISourcesRepository sources,
     IEntityReplaceService updateService)
 {
     _collections   = collections;
     _sources       = sources;
     _updateService = updateService;
 }
Ejemplo n.º 7
0
 public ExtractPages(
     ISourcesRepository sources,
     ISourceImageService imageService,
     IUriTemplateMatcher matcher,
     ISourceContext sourcesContext,
     ISourcesPersistence persistence)
 {
     this.sources        = sources;
     this.imageService   = imageService;
     this.matcher        = matcher;
     this.sourcesContext = sourcesContext;
     this.persistence    = persistence;
     this.Client         = new HttpClient();
 }
        public SourcesUpdateModule(
            ISourcesPersistence persistence,
            ISourcesRepository repository,
            IModelTemplateProvider modelTemplateProvider,
            IUriTemplateExpander expander,
            IPdfService pdfService)
            : base(modelTemplateProvider)
        {
            this.RequiresAnyPermissions(Permissions.WriteSources, Permissions.AdminSources);

            this.expander   = expander;
            this.pdfService = pdfService;
            this.Put <Brochure>(async r =>
                                await this.PutSingle(brochure => persistence.SaveBrochure(brochure), repository.GetBrochure));
            this.Post <SourceContent>(
                async r => await this.UploadPdf((int)r.id, repository.GetBrochure, brochure => persistence.SaveBrochure(brochure, true)));
            this.Delete <SourceContent>(
                async r => await this.DeletePdf((int)r.id, repository.GetBrochure, brochure => persistence.SaveBrochure(brochure, true)));
            using (this.Templates)
            {
                this.Post <Collection <Brochure> >(async r =>
                                                   await this.CreateBrochure(persistence.CreateBrochure, repository.GetBrochure));
            }
        }
Ejemplo n.º 9
0
 public SourcesManager(ISourcesRepository sourcesRepository)
 {
     _sourcesRepository = sourcesRepository;
 }