public MediaCenterContext() : base("MC_SQL") { MovieRepository = new MovieRepository(this); ShowRepository = new ShowRepository(this); EpisodeRepository = new EpisodeRepository(this); UserRepository = new UserRepository(this); }
public async Task CreateAsync_given_dto_returns_created_Episode() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var bender = new Character { Name = "Bender", Species = "Robot" }; var fry = new Character { Name = "Fry", Species = "Human" }; context.Characters.AddRange(bender, fry); await context.SaveChangesAsync(); var repository = new EpisodeRepository(context); var dto = new EpisodeCreateUpdateDTO { Title = "Murder on the Planet Express", FirstAired = new DateTime(2013, 8, 21), CharacterIds = new[] { bender.Id, fry.Id } }; var episode = await repository.CreateAsync(dto); Assert.Equal(1, episode.Id); Assert.Equal("Murder on the Planet Express", episode.Title); Assert.Equal(new DateTime(2013, 8, 21), episode.FirstAired); Assert.Equal(new Dictionary <int, string> { { bender.Id, "Bender" }, { fry.Id, "Fry" } }, episode.Characters); } }
public HomeController(ILogger <HomeController> logger, CharacterRepository characterRepository, EpisodeRepository episodeRepository, PlaneteRepository planeteRepository) { _logger = logger; _characterRepository = characterRepository; _episodeRepository = episodeRepository; _planeteRepository = planeteRepository; }
public async Task DeleteAsync_given_existing_episodeId_deletes_cascading() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var entity = new Episode { Title = "The Series Has Landed", EpisodeCharacters = new[] { new EpisodeCharacter { Character = new Character { Name = "Bender", Species = "Robot" } } } }; context.Episodes.Add(entity); await context.SaveChangesAsync(); var id = entity.Id; var repository = new EpisodeRepository(context); await repository.DeleteAsync(id); Assert.Null(await context.Episodes.FindAsync(id)); Assert.Empty(await context.EpisodeCharacters.ToListAsync()); Assert.NotNull(await context.Characters.FirstOrDefaultAsync(c => c.Name == "Bender")); } }
public async Task Read_returns_projection_of_all_episodes() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var episode1 = new Episode { Title = "Space Pilot 3000", FirstAired = new DateTime(1999, 3, 28) }; var episode2 = new Episode { Title = "The Series Has Landed", FirstAired = new DateTime(1999, 4, 4) }; context.Episodes.AddRange(episode1, episode2); await context.SaveChangesAsync(); var repository = new EpisodeRepository(context); var episodes = repository.Read().ToList(); Assert.Collection(episodes, e => { Assert.Equal("Space Pilot 3000", e.Title); Assert.Equal(new DateTime(1999, 3, 28), e.FirstAired); }, e => { Assert.Equal("The Series Has Landed", e.Title); Assert.Equal(new DateTime(1999, 4, 4), e.FirstAired); } ); } }
public StatService( EpisodeRepository episodeRepository, ILogger <StatService> logger) { _episodeRepository = episodeRepository; _logger = logger; }
public IEnumerable <Episode> Get() { var r = new EpisodeRepository(); return(r.GetMockEpisodes()); //return new string[] { "value1", "value2" }; }
public EpisodeRepositoryShould() { var dbLogger = new Mock <ILogger <InMemoryContext> >(); var db = new InMemoryContext(dbLogger.Object); var logger = new Mock <ILogger <EpisodeRepository> >(); _episodeRepository = new EpisodeRepository(db, logger.Object); }
public bool Logic() { var logs = new List <Log>(); try { logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, "Starting Checker logic", null)); var showRepo = new ShowRepository(ConnectionString); var episodeRepo = new EpisodeRepository(ConnectionString); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, "Getting enabled shows in database", null)); var showsInDatabase = showRepo.Select().Where(x => x.Enabled == true && x.Download == true).ToList(); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Found {showsInDatabase.Count} shows in database", null)); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, "Getting episodes in database", null)); var episodesInDatabase = episodeRepo.Select(); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Found {episodesInDatabase.Count} episodes in database", null)); logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, "Looping through shows", null)); foreach (var show in showsInDatabase) { // Get total episodes and status logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, "Getting show data from source", null)); var status = GetStatus(show.Source, show.Url); // Check if current amount of episodes == total episodes and status is downloaded logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, "Getting episodes downloaded", null)); var episodesByShow = episodesInDatabase.Where(x => x.ShowId == show.Id && x.Status == EpisodeStatus.DOWNLOADED).ToList(); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Found {episodesByShow} episodes downloaded", null)); // if yes then disable drama -> Enabled = false logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, "Checking if it has to be disabled", null)); if (episodesByShow.Count == status.Item1 && status.Item2) { logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, $"Disabling show {show.Title}", null)); show.Enabled = false; showRepo.Update(show); } else { logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, $"{show.Title} is still in progres", null)); } } } catch (Exception e) { logs.Add(new Log(Core.Enums.LogHelpers.LogType.ERROR, e.Message, e.StackTrace)); } logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, "Finished Checker logic", null)); LogRepository.Create(logs); return(true); }
public PodcastService( PodcastRepository podcastRepository, EpisodeRepository episodeRepository, RssService rssService, TagsRepository tagsRepository) { _podcastRepository = podcastRepository; _episodeRepository = episodeRepository; _rssService = rssService; _tagsRepository = tagsRepository; }
public async Task DeleteAsync_given_non_existing_episodeId_returns_false() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var repository = new EpisodeRepository(context); var deleted = await repository.DeleteAsync(0); Assert.False(deleted); } }
private void CreateRepositories() { HttpClient = new HttpClient(); HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken); Albums = new AlbumRepository(HttpClient, new Uri(BaseUri, AlbumRepository.DEFAULT_ENDPOINT)); Artists = new ArtistRepository(HttpClient, new Uri(BaseUri, ArtistRepository.DEFAULT_ENDPOINT)); Browse = new BrowseRepository(HttpClient, new Uri(BaseUri, BrowseRepository.DEFAULT_ENDPOINT)); Episodes = new EpisodeRepository(HttpClient, new Uri(BaseUri, EpisodeRepository.DEFAULT_ENDPOINT)); Recommendations = new RecommendationsRepository(HttpClient, new Uri(BaseUri, RecommendationsRepository.DEFAULT_ENDPOINT)); _search = new SearchRepository(HttpClient, new Uri(BaseUri, SearchRepository.DEFAULT_ENDPOINT)); }
public UnitOfWork(MediaCloudContext context) { _context = context; MovieLibraries = new MovieLibraryRepository(context); SeriesLibraries = new SeriesLibraryRepository(context); Libraries = new LibraryRepository(context); Items = new ItemRepository(context); Genres = new GenreRepository(context); Movies = new MovieRepository(context); Seasons = new SeasonRepository(context); Episodes = new EpisodeRepository(context); Media = new MediaRepository(context); }
public bool Logic() { var logs = new List <Log>(); try { logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, "Starting Downloader logic", null)); var showRepo = new ShowRepository(ConnectionString); var episodeRepo = new EpisodeRepository(ConnectionString); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Getting shows from database", null)); var showsInDatabase = showRepo.Select().Where(x => x.Download == true && x.Enabled == true).ToList(); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Found {showsInDatabase.Count} shows in database", null)); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Getting episodes from database", null)); var episodesInDatabase = episodeRepo.Select(); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Found {episodesInDatabase.Count} in database", null)); logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, $"Looping through shows that are enabled to download", null)); foreach (var show in showsInDatabase) { logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Checking episodes scraped", null)); var episodesByShow = episodesInDatabase.Where(x => x.ShowId == show.Id && x.Status == EpisodeStatus.SCRAPED).OrderBy(y => y.Filename).ToList(); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Found {episodesByShow.Count} to download", null)); foreach (var episode in episodesByShow) { logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, $"Downloading {episode.Filename}", null)); var path = System.IO.Path.Combine(Path, show.Title); episode.Status = DownloadHelpers.DownloadFile(episode.Url, path, episode.Filename) ? EpisodeStatus.DOWNLOADED : EpisodeStatus.FAILED; var downloadMessage = episode.Status == EpisodeStatus.DOWNLOADED ? "successfully" : "failed"; logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, $"Downladed {downloadMessage}", null)); episodeRepo.Update(episode); logs.Add(new Log(Core.Enums.LogHelpers.LogType.DEBUG, $"Updated show", null)); } } } catch (Exception e) { logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, e.Message, e.StackTrace)); } logs.Add(new Log(Core.Enums.LogHelpers.LogType.INFO, "Finished Downloader logic", null)); LogRepository.Create(logs); return(true); }
public async Task UpdateAsync_given_existing_dto_updates_entity() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var bender = new Character { Name = "Bender", Species = "Robot" }; var fry = new Character { Name = "Fry", Species = "Human" }; var entity = new Episode { Title = "Murder on the Planet Express", FirstAired = new DateTime(2013, 8, 21), EpisodeCharacters = new HashSet <EpisodeCharacter> { new EpisodeCharacter { Character = bender }, new EpisodeCharacter { Character = fry } } }; context.Episodes.Add(entity); await context.SaveChangesAsync(); var repository = new EpisodeRepository(context); var dto = new EpisodeCreateUpdateDTO { Id = entity.Id, Title = "The Series Has Landed", FirstAired = new DateTime(1999, 4, 4), CharacterIds = new HashSet <int> { bender.Id } }; var updated = await repository.UpdateAsync(dto); Assert.True(updated); var updatedEntity = await context.Episodes.Include(c => c.EpisodeCharacters).FirstOrDefaultAsync(c => c.Id == entity.Id); Assert.Equal("The Series Has Landed", updatedEntity.Title); Assert.Equal(new DateTime(1999, 4, 4), updatedEntity.FirstAired); Assert.Equal(bender.Id, updatedEntity.EpisodeCharacters.Single().CharacterId); } }
// ReSharper disable once InconsistentNaming public async Task GetEpisodeById_should_return_episode_by_id() { using (var context = CreateContext()) { await SeedEpisodesAsync(context); var repository = new EpisodeRepository(context); int id = 2; var episode = await repository.GetEpisodeById(id); Assert.Equal(id, episode.Id); } }
// ReSharper disable once InconsistentNaming public async Task GetEpisodesByShowIdAsync_should_return_empty_array_with_showId_that_does_not_exist() { using (var context = CreateContext()) { await SeedEpisodesAsync(context); var repository = new EpisodeRepository(context); int showId = 0; var episodes = await repository.GetEpisodesByShowIdAsync(showId); Assert.Equal(0, episodes.Length); } }
// ReSharper disable once InconsistentNaming public async Task GetEpisodeById_should_return_null_if_episode_does_not_exist() { using (var context = CreateContext()) { await SeedEpisodesAsync(context); var repository = new EpisodeRepository(context); int id = 42; var episode = await repository.GetEpisodeById(id); Assert.Null(episode); } }
private void AddEpisode(object parameter) { _episodeOperation.Status = EpisodeOperation.OperationStatus.OKAY; EpisodeRepository episodeRepository = new EpisodeRepository(); List <Episode> episodes = new List <Episode>(episodeRepository.GetAll()); NewEpisode.Id = (episodes.Count() + 1); EpisodeBusiness episodeBusiness = new EpisodeBusiness(); episodeBusiness.AddEpisode(NewEpisode); if (parameter is System.Windows.Window) { (parameter as System.Windows.Window).Close(); } }
public async Task UpdateAsync_given_non_existing_dto_returns_false() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var repository = new EpisodeRepository(context); var dto = new EpisodeCreateUpdateDTO { Id = 0, Title = "Dummy" }; var updated = await repository.UpdateAsync(dto); Assert.False(updated); } }
public EpisodeRepositoryShould() { // Given _dbLogger = new Mock <ILogger <AmstramgramContext> >(); // https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/in-memory _options = new DbContextOptionsBuilder <AmstramgramContext>() .UseInMemoryDatabase(databaseName: "Amstramgram_EpisodeRepositoryShould") .Options; using (var context = new AmstramgramContext(_options, _dbLogger.Object)) { context.EnsureSeedData(); } var starWarsContext = new AmstramgramContext(_options, _dbLogger.Object); var repoLogger = new Mock <ILogger <EpisodeRepository> >(); _episodeRepository = new EpisodeRepository(starWarsContext, repoLogger.Object); }
public static List <Episode> GetAll() { try { List <Episode> result; using (var context = new MediaManagerContext()) using (var repository = new EpisodeRepository(context)) { result = repository.GetAll(); } return(result); } catch (Exception ex) { throw new MediaManagerException($"Erreur : {ex.Message}", ExceptionReturnType.Error); } }
// ReSharper disable once InconsistentNaming public async Task GetEpisodesByShowIdAsync_should_return_episodes_with_a_given_showId() { using (var context = CreateContext()) { await SeedEpisodesAsync(context); var repository = new EpisodeRepository(context); int showId = 100; var episodes = await repository.GetEpisodesByShowIdAsync(showId); Assert.Equal(1, episodes.Length); Assert.Equal(showId, episodes.First().ShowId); } }
public async Task DeleteAsync_given_existing_episodeId_returns_true() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var entity = new Episode { Title = "The Series Has Landed" }; context.Episodes.Add(entity); await context.SaveChangesAsync(); var id = entity.Id; var repository = new EpisodeRepository(context); var deleted = await repository.DeleteAsync(id); Assert.True(deleted); } }
public async void InsertingEpisode_DataPassed_EpisodeInserted() { var builder = new DbContextOptionsBuilder(); builder.UseInMemoryDatabase("InsertNewEpisode"); using (var context = new StarWarsContext(builder.Options)) { var repository = new EpisodeRepository(context); repository.CreateEpisode(new Episode() { EpisodeName = "test episode" }); await repository.SaveChangesAsync(); }; using (var context2 = new StarWarsContext(builder.Options)) { Assert.Equal(1, context2.Episodes.Count()); } }
public static void Save(Episode element) { if (element == null) { throw new MediaManagerException($"Erreur : {nameof(element)} is null", ExceptionReturnType.Error); } try { using (var context = new MediaManagerContext()) using (var repository = new EpisodeRepository(context)) { repository.Save(element); context.SaveChanges(); } } catch (Exception ex) { throw new MediaManagerException($"Erreur :{ex.Message}", ExceptionReturnType.Error); } }
public static void Delete(int id) { if (id <= 0) { throw new MediaManagerException($"Erreur : {nameof(id)} <= 0", ExceptionReturnType.Error); } try { using (var context = new MediaManagerContext()) using (var repository = new EpisodeRepository(context)) { repository.Delete(id); context.SaveChanges(); } } catch (Exception ex) { throw new MediaManagerException($"Erreur : {ex.Message}", ExceptionReturnType.Error); } }
public static Episode Get(int id) { if (id <= 0) { throw new MediaManagerException($"Erreur : {nameof(id)} <= 0", ExceptionReturnType.Error); } try { Episode result; using (var context = new MediaManagerContext()) using (var repository = new EpisodeRepository(context)) { result = repository.Get(id); } return(result); } catch (Exception ex) { throw new MediaManagerException($"Erreur : {ex.Message}", ExceptionReturnType.Error); } }
public async Task FindAsync_given_id_exists_returns_dto() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var bender = new Character { Name = "Bender", Species = "Robot" }; var fry = new Character { Name = "Fry", Species = "Human" }; var entity = new Episode { Title = "Murder on the Planet Express", FirstAired = new DateTime(2013, 8, 21), EpisodeCharacters = new[] { new EpisodeCharacter { Character = bender }, new EpisodeCharacter { Character = fry } } }; context.Episodes.Add(entity); await context.SaveChangesAsync(); var repository = new EpisodeRepository(context); var episode = await repository.FindAsync(entity.Id); Assert.Equal(1, episode.Id); Assert.Equal("Murder on the Planet Express", episode.Title); Assert.Equal(new DateTime(2013, 8, 21), episode.FirstAired); Assert.Equal(new Dictionary <int, string> { { bender.Id, "Bender" }, { fry.Id, "Fry" } }, episode.Characters); } }
public async Task CreateAsync_given_dto_creates_new_Episode() { using (var connection = await CreateConnectionAsync()) using (var context = await CreateContextAsync(connection)) { var bender = new Character { Name = "Bender", Species = "Robot" }; var fry = new Character { Name = "Fry", Species = "Human" }; context.Characters.AddRange(bender, fry); await context.SaveChangesAsync(); var repository = new EpisodeRepository(context); var dto = new EpisodeCreateUpdateDTO { Title = "Murder on the Planet Express", FirstAired = new DateTime(2013, 8, 21), CharacterIds = new[] { bender.Id, fry.Id } }; var episode = await repository.CreateAsync(dto); Assert.Equal(1, episode.Id); var entity = await context.Episodes.FindAsync(episode.Id); Assert.Equal("Murder on the Planet Express", entity.Title); Assert.Equal(new DateTime(2013, 8, 21), entity.FirstAired); var characterIds = await context.EpisodeCharacters.Where(e => e.EpisodeId == episode.Id).Select(c => c.CharacterId).ToListAsync(); Assert.True(new HashSet <int> { bender.Id, fry.Id }.SetEquals(characterIds)); } }
public PodCastController() { _podcastRepository = new PodCastRepository(); _episodeRepository = new EpisodeRepository(); _rssFeed = new RSSFeed(); }
public SeasonController(ISeasonRepository seasonRepository, IEpisodeRepository episodeRepository, ISeriesRepository seriesRepository) { _seasonRepository = (SeasonRepository)seasonRepository; _episodeRepository = (EpisodeRepository)episodeRepository; _seriesRepository = (SeriesRepository)seriesRepository; }
static void Main(string[] args) { ActorRepository actorRepos = new ActorRepository(); CountryRepository countryRepos = new CountryRepository(); SeriesRepository seriesRepos = new SeriesRepository(); ProductionCompanyRepository productionCompanyRepos = new ProductionCompanyRepository(); GenreRepository genreRepos = new GenreRepository(); EpisodeRepository episodeRepos = new EpisodeRepository(); /// <summary> /// Jag har valt att använda async i min applikation för att simulera hur min seriedatabas /// skulle kunna användas som del av en webbapplikation. Man kan då tänka sig att man inte vill /// att webbsidan ska låsas helt tills en viss databasoperation har returnerat ett resultat, /// t.ex. en lista av skådespelare. För att hantera detta scenario lämpar sig async väl, /// det finns troligen inget behov av att utnyttja mer resurser för att skapa ytterligare /// trådar i detta scenario (då det att skapa fler trådar är resurskrävande). Ett annat /// argument för att välja async framför att skapa flera trådar är att man med async har /// bättre kontroll över flödet, det går att på ett enklare sätt spåra i koden när en /// specifik Task kommer att exekveras vilket gör att race conditions ej uppstår lika lätt. /// </summary> //var result = actorRepos.GetAllActorsAsync(); //Console.WriteLine("Waiting for list of actors. Adding a series while waiting."); //seriesRepos.Add(new Series { Title = "Gilmore girls", ProductionCompanyId = 9 }); //Console.WriteLine("Waiting for series to be added."); //var actors = actorRepos.FindActorByInitialsAsync("sk"); //Console.WriteLine("Waiting for findactorbyinitialasync method to finish."); //foreach(var actor in actors.Result) //{ // Console.WriteLine("Actors with given initials:" + actor.FirstName + " " + actor.LastName); //} //foreach (var a in result.Result) //{ // Console.WriteLine(a.FirstName + " " + a.LastName); //} //genreRepos.DeleteSeriesGenreConnection(1, 3); //genreRepos.UpdateGenreForOneSeries(1, 2, 3); //try //{ // seriesRepos.DeleteConnectionsBetweenActorAndSpecifiedSeries(35, new List<int> { 3 }); //} //catch (NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // countryRepos.DeleteCountriesByNameOrCode("Denmark"); //} //catch (NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //catch(ItemNotPossibleToDeleteException e) //{ // Console.WriteLine(e.Message); //} //try //{ // seriesRepos.DeleteManySeriesActors(35, new List<int> { 3, 27 }); //} //catch (NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //genreRepos.UpdateGenreForOneSeries(3, 4, 2); //genreRepos.DeleteSeriesGenreConnection(3, 2); //try //{ // seriesRepos.DeleteSeriesActorByActorId(35); //} //catch(NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // var country = countryRepos.GetCountryByCountryName("swe"); // Console.WriteLine(country.Name); //} //catch (NullReferenceException e) //{ // Console.WriteLine(e.Message); //} //actorRepos.Delete(new Actor { FirstName = "Stellan", LastName = "Skarsgård", Birthday = new DateTime (1951, 6, 13)}); //actorRepos.DeleteManyActorsByIds(new List<int> { 24, 25 }); //try //{ // var country = countryRepos.GetCountryByCountryName("sw"); // Console.WriteLine(country.Name); //} //catch(NullReferenceException e) //{ // Console.WriteLine(e.Message); //} //try //{ // var countries = countryRepos.GetAllCountriesByGenre("drama"); // foreach (var c in countries) // { // Console.WriteLine(c.Name); // } //} //catch (NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // var country = countryRepos.GetCountryForActor("stellan", "skarsgård"); // Console.WriteLine("Actor comes from: " + country.Name); //} //catch(NullReferenceException) //{ // Console.WriteLine ("No actor with that name is found in database"); //} //try //{ // actorRepos.DeleteActorsByCountry("Germany"); //} //catch (NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //countryRepos.AddRange(new Country { Name = "Denmark", CountryCode = "DK"}); //productionCompanyRepos.Add(new ProductionCompany { Name = "Nimbus Film", CountryId = 10 }); //actorRepos.AddRange(new List<Actor> //{ // new Actor { FirstName = "Zooey", LastName = "Deschanel", Birthday = new DateTime(1980, 1, 17), CountryId = 7 }, // new Actor { FirstName = "Jake", LastName = "Johnson", Birthday = new DateTime(1978, 5, 28), CountryId = 7 }, // new Actor { FirstName = "Max", LastName = "GreenField", Birthday = new DateTime(1980, 9, 4), CountryId = 7 }, //// new Actor { FirstName = "Stellan", LastName = "Skarsgård", Birthday = new DateTime(1951, 6, 13), CountryId = 3}, //// new Actor { FirstName = "Erin", LastName = "Karpluk", Birthday = new DateTime(1978, 10, 17), CountryId = 1}, //// new Actor { FirstName = "Hugh", LastName = "Bonneville", Birthday = new DateTime(1963, 11, 10), CountryId = 2 }, //// new Actor { FirstName = "Laura", LastName = "Carmichael", Birthday = new DateTime(1986, 7, 16), CountryId = 2 }, //// new Actor { FirstName = "Jim", LastName = "Carter", Birthday = new DateTime(1948, 8, 19), CountryId = 2 }, //// new Actor { FirstName = "Michelle", LastName = "Dockery", Birthday = new DateTime(1981, 12, 15), CountryId = 2} //}); //productionCompanyRepos.AddRange(new List<ProductionCompany> //{ // new ProductionCompany {Name = "BBC", CountryId = 2}, // new ProductionCompany {Name = "Fox", CountryId = 4}, // new ProductionCompany {Name = "Produktion i Väst", CountryId = 3 }, // new ProductionCompany {Name = "Buccaner Media", CountryId = 2}, // new ProductionCompany {Name = "UFA Fiction", CountryId = 5}, // new ProductionCompany {Name = "Temple Street Productions", CountryId = 1} //}); // productionCompanyRepos.Add(new ProductionCompany { Name = "Gallery Picture", CountryId = 2 }); //seriesRepos.AddRange(new List<Series> //{ // new Series {Title = "Being Erica", ProductionCompanyId = 6 }, // new Series {Title = "Downton Abbey", ProductionCompanyId = 1}, // new Series {Title = "River", ProductionCompanyId = 7}, // new Series {Title = "New Girl", ProductionCompanyId = 2}, // new Series {Title = "Silent Hours", ProductionCompanyId = 8}, // new Series {Title = "Deutschland 83", ProductionCompanyId = 5} //}); //var country = countryRepos.FindBy(c => c.Name.StartsWith("G")); //foreach (var c in country) //{ // Console.WriteLine(c.Name); //} //countryRepos.UpdateById(7, c => { // c.CountryCode = "US"; // return c; // }); //seriesActorRepos.ConnectActorToSeries(4, new List<int> { 6 }); //countryRepos.AddRange(new List<Country> //{ // new Country{Name = "Canada", CountryCode = "CA"}, // new Country{Name = "Great Britain", CountryCode = "GB"}, // new Country{Name = "Sweden", CountryCode = "SE"}, // new Country{Name = "United States of America", CountryCode = "USA"}, // new Country{Name = "Germany", CountryCode = "DE"} //}); //foreach (var result in seriesRepos.GetSeriesWithGenres(new List<int> { 2, 3 })) //{ // Console.WriteLine(result.Item1.Title); // foreach (var g in result.Item2) // { // Console.WriteLine(g.Name); // } //} //var result = genreRepos.GetAllGenresWithAllSeries(); //if (null != result) //{ // foreach(var s in result) // { // Console.WriteLine(s.Item1.Name); // foreach(var g in s.Item2) // { // Console.WriteLine(g.Title); // } // } //} //try //{ // var result = seriesRepos.GetSeriesByGenre("River"); // foreach (var s in result) // { // Console.WriteLine(s.Title); // } //} //catch(NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // var s = seriesRepos.GetSeriesByReleaseYear(2008); // foreach (var se in s) // { // if(null != se.Title) // { // Console.WriteLine(se.Title); // } // } //} //catch(NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // seriesRepos.ConnectActorToSeries( 24, new List<int> { 27}); //} //catch (NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //var result = seriesRepos.GetAllSeriesByActorNameAndCountryName("Michelle", "Great Britain"); //foreach(var s in result) //{ // Console.WriteLine(s.Title); //} //var a = seriesRepos.ProjectionLoadSeries("Downton abbey"); //Console.WriteLine("Title of series: " + a.Title + "\tProductioncompany: " + // a.ProductionCompany.Name + "\tCountry for productioncompany: " + a.ProductionCompany.Country.Name); // var result = episodeRepos.GetEpisodesForOneSeries("Being Erica"); // Console.WriteLine(result.Item1.Title); // foreach (var e in result.Item2) // { // Console.WriteLine(e.Title); // } //} //catch(NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try // { // episodeRepos.DeleteEpisodesBySeriesID(90); // } // catch(NoSuchItemException e) // { // Console.WriteLine(e.Message); // } //episodeRepos.AddRange(new List<Episode> //{ // new Episode{SeriesId = 2, SeasonNumber = 1, ReleaseDate = new DateTime(2010, 9, 26)}, // new Episode{Title = "Dr. Tom", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 1, 9)}, // new Episode{SeriesId = 2, SeasonNumber = 1, ReleaseDate = new DateTime(2010, 10, 3)}, // new Episode{SeriesId = 2, SeasonNumber = 1, ReleaseDate = new DateTime(2010, 10, 10)}, // new Episode{SeriesId = 2, SeasonNumber = 1, ReleaseDate = new DateTime(2010, 10, 17)}, // new Episode{SeriesId = 2, SeasonNumber = 1, ReleaseDate = new DateTime(2010, 10, 24)}, // new Episode{SeriesId = 2, SeasonNumber = 1, ReleaseDate = new DateTime(2010, 10, 31)}, // new Episode{SeriesId = 2, SeasonNumber = 1, ReleaseDate = new DateTime(2010, 11, 7)}, // new Episode{Title = "What I am is what I am", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 2, 26)}, // new Episode{Title = "Plenty of fish", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 3, 5)}, // new Episode{Title = "The secret of now", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 3, 12)}, // new Episode{Title = "Adultescence", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 3, 19)}, // new Episode{Title = "Til death", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 3, 26)}, // new Episode{Title = "Such a perfect day", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 4, 2)}, // new Episode{Title = "This be the verse", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 4, 9)}, // new Episode{Title = "Everything she wants", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 4, 16)}, // new Episode{Title = "Mi casa su casa loma", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 4, 23)}, // new Episode{Title = "She's lost control", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 4, 30)}, // new Episode{Title = "Erica the vampire slayer", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 5, 7)}, // new Episode{Title = "Leo", SeriesId = 1, SeasonNumber = 1, ReleaseDate = new DateTime(2009, 5, 14)}, //}); //try //{ // var genres = genreRepos.GetGenresForSeries(new List<int> { 98 }); // foreach (var g in genres) // { // Console.WriteLine("Genre: " + g.Name); // } //} //catch(NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // var series = genreRepos.GetOneGenreWithSeries("Romance"); // Console.WriteLine(series.Item1.Name + " series: "); // foreach (var s in series.Item2) // { // Console.WriteLine(s.Title); // } //} //catch(NullReferenceException) //{ // Console.WriteLine("No such genre in database"); //} //var seriesGenres = genreRepos.GetAllGenresWithAllSeries(); //foreach(var g in seriesGenres) //{ // Console.WriteLine("Genre: " + g.Item1.Name); // foreach(var s in g.Item2) // { // Console.WriteLine("Series: " + s.Title); // } //} //try //{ // var result = seriesRepos.GetSeriesByGenreAndCountry("comedy", "great brin"); // foreach (var a in result) // { // Console.WriteLine(a.Title); // } //} //catch (NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //var result = productionCompanyRepos.GetAllProductionCompaniesInCountry("Sweden"); //foreach(var p in result) //{ // Console.WriteLine(p.Name); //} //productionCompanyRepos.UpdateProductionCompanyCountry(8, // 7); //try //{ // seriesRepos.DeleteSeriesByGenre("drama"); //} //catch(NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // seriesRepos.AddConnectionBetweenOneSeriesAndOneGenre(45, 2); //} //catch(DbUpdateException e) //{ // Console.WriteLine(e.Message); //} //try //{ // seriesRepos.ConnectSeriesToActors(new List<int> { 27 }, new List<int> { 37}); //} //catch (NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // var actors = actorRepos.FindActorsByInitials("ze"); // foreach (var a in actors) // { // Console.WriteLine(a.FirstName + " " + a.LastName); // } //} //catch (NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // var result = actorRepos.GetActorsWithNationality(); // foreach(var a in result) // { // Console.WriteLine(a.FirstName + " " + a.LastName); // Console.WriteLine(a.Country.Name); // } //} //catch(NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // actorRepos.DeleteActorById(21); // Console.WriteLine("Actor deleted as well as connected posts in actorseries table."); //} //catch(NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //actorRepos.UpdateActorLastName("bonneville", "boville"); // seriesRepos.ConnectSeriesToActor(2, new List<int> { 24, 37}); //try //{ // seriesRepos.DeleteSeriesByTitle("ghhd"); //} //catch(NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} //try //{ // productionCompanyRepos.UpdateProductionCompanyForSeries(7, 11); //} //catch (NoSuchItemException e) //{ // Console.WriteLine(e.Message); //} }
public UnitOfWork() { EpisodeRepository = new EpisodeRepository(_Context); SitcomRepository = new SitcomRepository(_Context); }
// ReSharper disable once InconsistentNaming public async Task GetEpisodesByTheTvDbIdsAsync_should_return_empty_array_when_called_with_empty_array() { using (var context = CreateContext()) { await SeedEpisodesAsync(context); var repository = new EpisodeRepository(context); var episodes = await repository.GetEpisodesByTheTvDbIdsAsync(Array.Empty<int>()); Assert.Equal(0, episodes.Length); } }
// ReSharper disable once InconsistentNaming public async Task GetEpisodesByTheTvDbIdsAsync_should_return_episodes_with_mathing_ids() { using (var context = CreateContext()) { await SeedEpisodesAsync(context); var repository = new EpisodeRepository(context); int[] ids = { 10, 20, 30 }; var episodes = await repository.GetEpisodesByTheTvDbIdsAsync(ids); Assert.Equal(ids.Length, episodes.Length); for (int i = 0; i < episodes.Length; i++) { Assert.Equal(ids[i], episodes[i].TheTvDbId); } } }
public List<Episode> ListEpisodes(double waveId) { FeatureRepository<Episode> repository = new EpisodeRepository(); return repository.ListFeatures (waveId); }