Beispiel #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using var dbContext = new TvMazeScraperContext(serviceProvider.GetRequiredService <DbContextOptions <TvMazeScraperContext> >());
            if (dbContext.Shows.Any())
            {
                return;
            }

            PopulateTestData(dbContext);
        }
 public ScraperService(
     ILogger <ScraperService> logger,
     ITvMazeHttpClient httpClient,
     MazeApiSettings mazeApiSettings,
     TvMazeScraperContext context)
 {
     _logger          = logger;
     _httpClient      = httpClient;
     _mazeApiSettings = mazeApiSettings;
     _context         = context;
 }
Beispiel #3
0
        public static void PopulateTestData(TvMazeScraperContext dbContext)
        {
            var shows = new List <Show>
            {
                new Show {
                    Id = 1, Name = "Test show 1"
                },
                new Show {
                    Id = 2, Name = "Test show 2"
                }
            };

            var persons = new List <Person>
            {
                new Person {
                    Id = 1, Name = "Test person 1", Birthday = new DateTime(1950, 1, 1)
                },
                new Person {
                    Id = 2, Name = "Test person 2", Birthday = new DateTime(1950, 1, 1)
                }
            };

            var cast = new List <ShowPerson>
            {
                new ShowPerson {
                    PersonId = 1, ShowId = 1
                },
                new ShowPerson {
                    PersonId = 2, ShowId = 2
                }
            };

            dbContext.Shows.AddRange(shows);
            dbContext.Persons.AddRange(persons);
            dbContext.ShowPerson.AddRange(cast);

            dbContext.SaveChanges();
        }
 public ShowWriteRepository(TvMazeScraperContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Beispiel #5
0
 public ProcessingStateRepository(TvMazeScraperContext context)
 {
     _context = context;
 }
Beispiel #6
0
 public ShowService(TvMazeScraperContext context)
 {
     _context = context;
 }
 public ShowReadRepository(TvMazeScraperContext context)
 {
     _context = context;
 }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TvMazeScraperRepository"/> class.
 /// </summary>
 /// <param name="context">The db context containing the Tv shows and actors.</param>
 public TvMazeScraperRepository(TvMazeScraperContext context)
 {
     _dbContext = context;
 }
Beispiel #9
0
 public UpdatingStateRepository(TvMazeScraperContext context)
 {
     _context = context;
 }