public IHttpActionResult Get(int id) { EpisodeService episodeService = CreateEpisodeService(); var episode = episodeService.ReadEpisodeById(id); return(Ok(episode)); }
/// <summary> /// Handles the Loaded event of the DownloadIndex control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void DownloadIndex_Loaded( object sender, RoutedEventArgs e) { EpisodeService service; try { service = new EpisodeService( App.Repositories, App.Downloader, App.EpisodeSaver); } catch (ServiceException ex) { App.HandleException( "Download index cannot be displayed.", ex); return; } try { this.episodesListBox.ItemsSource = service.GetDownloadIndex(); } catch (RepositoryException ex) { App.HandleException( "Download index data could not be retrieved.", ex); throw; } }
private EpisodeService CreateEpisodeService() { var userId = Guid.Parse(User.Identity.GetUserId()); var episodeService = new EpisodeService(userId); return(episodeService); }
public AddEpisodeModel(AnimeService animeService, EpisodeService episodeService, IMapper mapper) { this.mapper = mapper; this.animeService = animeService; this.episodeService = episodeService; this.LinksViewModel = new LinksViewModel(); }
public IHttpActionResult Get() { EpisodeService episodeService = CreateEpisodeService(); var episodes = episodeService.ReadEpisodes(); return(Ok(episodes)); }
public void Add_EpNotInDB_WritesToDb() { Episode ep1 = new Episode() { SeriesId = 328487, TVDBEpisodeId = 6089488, Season = 1, AiredEpisodeNumber = 1, EpisodeName = "Old Wounds" }; int expectedEpisodeId = 6089488; string expectedEpisodeName = "Old Wounds"; var options = new DbContextOptionsBuilder <EpisodeContext>() .UseInMemoryDatabase(databaseName: "Add_EpNotInDB_WritesToDb") .Options; // Act using (var context = new EpisodeContext(options)) { var service = new EpisodeService(context); service.Add(ep1); } using (var context = new EpisodeContext(options)) { var service = new EpisodeService(context); var result = context.Episodes.FirstOrDefault(e => e.TVDBEpisodeId == expectedEpisodeId); Assert.NotNull(result); Assert.Equal(expectedEpisodeName, result.EpisodeName); } }
public void Constructor_101_OK() { var episodeService = new EpisodeService( TestApp.Repositories, null, TestApp.EpisodeSaver); }
public void Constructor_110_OK() { var episodeService = new EpisodeService( TestApp.Repositories, TestApp.PodCastDownloader, null); }
public void Constructor_000_OK() { var episodeService = new EpisodeService( null, null, null); }
public void Initialize() { _episodeService = new EpisodeService { Token = TestSettings.Token, ApiKey = TestSettings.ApiKey, UserAgent = TestSettings.UserAgent }; }
public WatchModel(EpisodeService episodeService, AnimeService animeService, CategoryService categoryService, UserService profileService, UserManager <User> userManager) { this.EpisodeService = episodeService; this.AnimeService = animeService; this.CategoryService = categoryService; this.ProfileService = profileService; this.UserManager = userManager; this.WatchEpisodeViewModel = new WatchEpisodeViewModel(); }
private static async Task SeedSourceLinks(EpisodeService episodeService) { foreach (var link in SourceLinks) { if (!await episodeService.SourceLinkExistsAsync(link.Name)) { await episodeService.AddAnimeLinkEnumAsync(link); } } }
public void GetEpisode_ReturnsEpisodeDoesntExistMessageException(long episodeId) { //arrange var _episodeService = new EpisodeService(episodeRatingRepository); //assert Assert.Throws(Is.TypeOf <Exception>() .And.Message.EqualTo("Episode doesn't exist"), () => _episodeService.GetEpisode(episodeId)); }
public void GetEpisodes_ReturnsProperEpisodesCount() { //arrange var _episodeService = new EpisodeService(episodeRatingRepository); //act var episodes = _episodeService.GetEpisodesList(); //assert Assert.AreEqual(6, episodes.Count()); }
public async Task <ActionResult <EpisodeMetadata> > GetOneEpisode(string id, [FromServices] EpisodeService episodeService) { try { return(Ok(await episodeService.GetEpisodeMetadataAsync(id))); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public void GetEpisode_ReturnsEpisodeDetails(long episodeId, string title) { //arrange var _episodeService = new EpisodeService(episodeRatingRepository); //act var episodes = _episodeService.GetEpisode(episodeId); //assert Assert.AreEqual(title, episodes.Title); }
static async Task Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() .WriteTo.File("c:\\temp\\logs\\renamerLog.txt", rollingInterval: RollingInterval.Day) .CreateLogger(); Log.Information("Started log on {a}", DateTime.Now.ToLongTimeString()); SetUpVT100(); string projectRoot = AppContext.BaseDirectory.Substring(0, AppContext.BaseDirectory.LastIndexOf(@"\bin")); // PrintDirectories(appRoot); var builder = new ConfigurationBuilder() .SetBasePath(projectRoot) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); // IConfigurationRoot configuration = builder.Build(); Configuration = builder.Build(); var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider(); var httpClientFactory = serviceProvider.GetService <IHttpClientFactory>(); var options = new DbContextOptionsBuilder <EpisodeContext>() .UseSqlite(Configuration.GetConnectionString("connectionString")) .Options; var context = new EpisodeContext(options); TVDBRetrieverService retrieverService = new TVDBRetrieverService(httpClientFactory); TVShowService showService = new TVShowService(context); EpisodeService epService = new EpisodeService(context); LocalMediaService localService = new LocalMediaService(Configuration.GetSection("LocalMedia").GetValue <string>("directoryPath")); string tvdbInfoPath = GetTVDBInfoFilePath(); RenamePrompterConsole prompterConsole = new RenamePrompterConsole(); RenamerFacade facade = new RenamerFacade(retrieverService, showService, epService, localService, context, prompterConsole, tvdbInfoPath); MainMenu mainMenu = new MainMenu(facade, context, showService); await mainMenu.DisplayMenu(); // await DisplayMenuAndProcessUserInput(facade); // SetUpAutomapper(); // GetNewToken(httpClientFactory); // GetApiKey(); //ReadTVDBInfo(); // FindSampleShow(context); // PauseForInput(); // Console.WriteLine("Adding show"); //AddSampleShow(context); }
protected async Task DeleteEpisode(Chapter OneChapter, Episode OneEpisode) { MessageBoxDialogResult result = await ModalDialog.ShowMessageBoxAsync("Confirm Delete", "Are you sure you want to delete the episode ?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2); if (result == MessageBoxDialogResult.Yes) { await EpisodeService.DeleteEpisode(OneEpisode.Id); OneChapter.Episodes.Remove(OneEpisode); StateHasChanged(); } }
public void FindByEpisodeForComparingDto_EpInDB_ReturnsEp() { TVShow show = new TVShow() { SeriesId = 328487, SeriesName = "The Orville" }; Episode ep1 = new Episode() { SeriesId = 328487, TVDBEpisodeId = 6089488, Season = 1, AiredEpisodeNumber = 1, EpisodeName = "Old Wounds" }; Episode ep2 = new Episode() { SeriesId = 328487, TVDBEpisodeId = 6123044, Season = 1, AiredEpisodeNumber = 2, EpisodeName = "Command Performance" }; EpisodeForComparingDto epDto = new EpisodeForComparingDto() { SeriesName = "the orville", SeasonNumber = 1, EpisodeNumberInSeason = 1 }; string expectedEpisodeName = "Old Wounds"; var options = new DbContextOptionsBuilder <EpisodeContext>() .UseInMemoryDatabase(databaseName: "FindByEpisodeForComparingDto_EpInDB_ReturnsEp") .Options; using (var context = new EpisodeContext(options)) { var service = new EpisodeService(context); var TVService = new TVShowService(context); TVService.Add(show); service.Add(ep1); service.Add(ep2); } using (var context = new EpisodeContext(options)) { var service = new EpisodeService(context); Episode result = service.FindByEpisodeForComparingDto(epDto); Assert.NotNull(result); Assert.Equal(expectedEpisodeName, result.EpisodeName); } }
private static async Task SeedEpisodes(EpisodeService episodeService) { foreach (var episode in AnimeEpisodes) { if (!await episodeService.AnimeEpisodeExistsAsync(episode.AnimeSeriesId, episode.EpisodeNumber)) { foreach (var srcLink in episode.Links) { await episodeService.AddSourceLinkToEpisodeAsync(episode.AnimeSeriesId, srcLink.SourceId, srcLink.SourceUrl, episode.EpisodeNumber); } } } }
protected async Task AddEpisode(Chapter OneChapter) { if (OneQuiz.Id == 0) { var response = await ModalDialog.ShowMessageBoxAsync("Question", "Do you want to save this new quiz ?", MessageBoxButtons.YesNo); if (response == MessageBoxDialogResult.No) { return; } var result = await TrySavingChanges(); if (result == false) { return; } } ModalDialogParameters parameters = new ModalDialogParameters(); parameters.Add("Title", ""); parameters.Add("VideoId", ""); parameters.Add("Duration", 0); parameters.Add("Trailer", ""); var dialogResult = await ModalDialog.ShowDialogAsync <EpisodeEdit>("Add episode", new ModalDialogOptions(), parameters); if (dialogResult.Success) { var episode = new Episode { Title = dialogResult.ReturnParameters.Get <string>("Title"), VideoId = dialogResult.ReturnParameters.Get <string>("VideoId"), Duration = dialogResult.ReturnParameters.Get <int>("Duration"), Trailer = dialogResult.ReturnParameters.Get <string>("Trailer"), ChapterId = OneChapter.Id }; if (OneChapter.Episodes == null) { OneChapter.Episodes = new List <Episode>(); } OneChapter.Episodes.Add(episode); await EpisodeService.AddEpisode(episode); StateHasChanged(); } }
protected async Task EditEpisode(Chapter OneChapter, Episode OneEpisode) { ModalDialogParameters parameters = new ModalDialogParameters(); parameters.Add("Title", OneEpisode.Title); parameters.Add("VideoId", OneEpisode.VideoId); parameters.Add("Duration", OneEpisode.Duration); parameters.Add("Trailer", OneEpisode.Trailer); var dialogResult = await ModalDialog.ShowDialogAsync <EpisodeEdit>("Edit episode", new ModalDialogOptions(), parameters); if (dialogResult.Success) { OneEpisode.Title = dialogResult.ReturnParameters.Get <string>("Title"); OneEpisode.VideoId = dialogResult.ReturnParameters.Get <string>("VideoId"); OneEpisode.Duration = dialogResult.ReturnParameters.Get <int>("Duration"); OneEpisode.Trailer = dialogResult.ReturnParameters.Get <string>("Trailer"); await EpisodeService.UpdateEpisode(OneEpisode); } }
public void AddEpisodeToShow_ShowIsInDB_AddsEp() { TVShow show = new TVShow() { SeriesId = 328487, SeriesName = "The Orville" }; Episode ep1 = new Episode() { SeriesId = 328487, TVDBEpisodeId = 6089488, Season = 1, AiredEpisodeNumber = 1, EpisodeName = "Old Wounds", LastUpdated = DateTimeOffset.FromUnixTimeMilliseconds(1527457806).DateTime.ToLocalTime() }; int expectedEpisodeId = 6089488; string expectedEpisodeName = "Old Wounds"; var options = new DbContextOptionsBuilder <EpisodeContext>() .UseInMemoryDatabase(databaseName: "AddEpisodeToShow_ShowIsInDB_AddsEp") .Options; // Act using (var context = new EpisodeContext(options)) { var service = new EpisodeService(context); var TVService = new TVShowService(context); TVService.Add(show); service.AddEpisodeToShow(ep1); } using (var context = new EpisodeContext(options)) { var service = new EpisodeService(context); var result = context.Episodes.FirstOrDefault(e => e.TVDBEpisodeId == expectedEpisodeId); Assert.NotNull(result); Assert.Equal(expectedEpisodeName, result.EpisodeName); } }
public void FindByEpisodeForComparingDto_EpNotInDB_ReturnsNull() { TVShow show = new TVShow() { SeriesId = 328487, SeriesName = "The Orville" }; Episode ep1 = new Episode() { SeriesId = 328487, TVDBEpisodeId = 6089488, Season = 1, AiredEpisodeNumber = 1, EpisodeName = "Old Wounds" }; EpisodeForComparingDto epDto = new EpisodeForComparingDto() { SeriesName = "the chilling adventures of sabrina", SeasonNumber = 1, EpisodeNumberInSeason = 1 }; var options = new DbContextOptionsBuilder <EpisodeContext>() .UseInMemoryDatabase(databaseName: "FindByEpisodeForComparingDto_EpNotInDB_ReturnsNull") .Options; using (var context = new EpisodeContext(options)) { var service = new EpisodeService(context); var TVService = new TVShowService(context); TVService.Add(show); service.Add(ep1); } using (var context = new EpisodeContext(options)) { var service = new EpisodeService(context); Episode result = service.FindByEpisodeForComparingDto(epDto); Assert.Null(result); } }
public static void Seed(this IApplicationBuilder app) { var serviceFactory = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>(); var scoped = serviceFactory.CreateScope(); using (scoped) { RoleManager <IdentityRole> roleManager = scoped.ServiceProvider.GetRequiredService <RoleManager <IdentityRole> >(); UserManager <User> userManager = scoped.ServiceProvider.GetRequiredService <UserManager <User> >(); AnimeService animeService = scoped.ServiceProvider.GetRequiredService <AnimeService>(); EpisodeService episodeService = scoped.ServiceProvider.GetRequiredService <EpisodeService>(); CategoryService categoryService = scoped.ServiceProvider.GetRequiredService <CategoryService>(); SeedRoles(roleManager).GetAwaiter().GetResult(); SeedUsers(userManager).GetAwaiter().GetResult(); SeedCategories(categoryService).GetAwaiter().GetResult(); SeedAnimeSeries(animeService).GetAwaiter().GetResult(); SeedAnimeSeriesCategories(categoryService).GetAwaiter().GetResult(); SeedSourceLinks(episodeService).GetAwaiter().GetResult(); SeedEpisodes(episodeService).GetAwaiter().GetResult(); } }
/// <summary> /// Initializes a new instance of the <see cref="EpisodeIndex"/> class. /// </summary> /// <param name="podCastId">The pod cast id.</param> public EpisodeIndex( int podCastId) { this.InitializeComponent(); try { this.service = new EpisodeService( App.Repositories, App.Downloader, App.EpisodeSaver); } catch (ServiceException ex) { App.HandleException( "Service could not be loaded.", ex); return; } this.podCastId = podCastId; this.Loaded += this.EpisodeIndex_Loaded; }
public async Task <ActionResult <IEnumerable <EpisodeGeoEntity> > > GetAllEpisodes([FromServices] EpisodeService episodeService) { try { return(Ok(await episodeService.GetAllEpisodesAsync())); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public EpisodeController(IMediator mediator, EpisodeService episodeService) { _episodeService = episodeService; _mediator = mediator; }
public BaseController(AnimeService animeService, CategoryService categoryService, EpisodeService episodeService, IMapper mapper) { this.Mapper = mapper; this.AnimeService = animeService; this.CategoryService = categoryService; this.EpisodeService = episodeService; }
public AnimeController(AnimeService animeService, CategoryService categoryService, EpisodeService episodeService, UserService profileService, IMapper mapper) : base(animeService, categoryService, episodeService, mapper) { this.ProfileService = profileService; }