Пример #1
0
        public IHttpActionResult Get(int id)
        {
            EpisodeService episodeService = CreateEpisodeService();
            var            episode        = episodeService.ReadEpisodeById(id);

            return(Ok(episode));
        }
Пример #2
0
        /// <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;
            }
        }
Пример #3
0
        private EpisodeService CreateEpisodeService()
        {
            var userId         = Guid.Parse(User.Identity.GetUserId());
            var episodeService = new EpisodeService(userId);

            return(episodeService);
        }
Пример #4
0
 public AddEpisodeModel(AnimeService animeService, EpisodeService episodeService, IMapper mapper)
 {
     this.mapper         = mapper;
     this.animeService   = animeService;
     this.episodeService = episodeService;
     this.LinksViewModel = new LinksViewModel();
 }
Пример #5
0
        /// <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;
            }
        }
Пример #6
0
        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);
            }
        }
Пример #8
0
 public void Constructor_101_OK()
 {
     var episodeService =
         new EpisodeService(
             TestApp.Repositories,
             null,
             TestApp.EpisodeSaver);
 }
Пример #9
0
 public void Constructor_110_OK()
 {
     var episodeService =
         new EpisodeService(
             TestApp.Repositories,
             TestApp.PodCastDownloader,
             null);
 }
Пример #10
0
 public void Constructor_000_OK()
 {
     var episodeService =
         new EpisodeService(
             null,
             null,
             null);
 }
Пример #11
0
		public void Initialize()
		{
			_episodeService = new EpisodeService
			{
				Token = TestSettings.Token,
				ApiKey = TestSettings.ApiKey,
				UserAgent = TestSettings.UserAgent
			};
		}
Пример #12
0
 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();
 }
Пример #13
0
 public void Initialize()
 {
     _episodeService = new EpisodeService
     {
         Token     = TestSettings.Token,
         ApiKey    = TestSettings.ApiKey,
         UserAgent = TestSettings.UserAgent
     };
 }
Пример #14
0
 private static async Task SeedSourceLinks(EpisodeService episodeService)
 {
     foreach (var link in SourceLinks)
     {
         if (!await episodeService.SourceLinkExistsAsync(link.Name))
         {
             await episodeService.AddAnimeLinkEnumAsync(link);
         }
     }
 }
Пример #15
0
        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));
        }
Пример #16
0
        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));
     }
 }
Пример #18
0
        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);
        }
Пример #19
0
        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);
        }
Пример #20
0
        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();
            }
        }
Пример #21
0
        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);
            }
        }
Пример #22
0
 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);
             }
         }
     }
 }
Пример #23
0
        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();
            }
        }
Пример #24
0
        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);
            }
        }
Пример #25
0
        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);
            }
        }
Пример #26
0
        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);
            }
        }
Пример #27
0
        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();
            }
        }
Пример #28
0
        /// <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));
     }
 }
Пример #30
0
 public EpisodeController(IMediator mediator, EpisodeService episodeService)
 {
     _episodeService = episodeService;
     _mediator       = mediator;
 }
Пример #31
0
 public BaseController(AnimeService animeService, CategoryService categoryService, EpisodeService episodeService, IMapper mapper)
 {
     this.Mapper          = mapper;
     this.AnimeService    = animeService;
     this.CategoryService = categoryService;
     this.EpisodeService  = episodeService;
 }
Пример #32
0
 public AnimeController(AnimeService animeService, CategoryService categoryService, EpisodeService episodeService, UserService profileService, IMapper mapper)
     : base(animeService, categoryService, episodeService, mapper)
 {
     this.ProfileService = profileService;
 }