Exemple #1
0
        /// <summary>
        /// Get a list of every movie directory
        /// </summary>
        /// <returns></returns>
        public async Task <int> Insert(LibGenTvShow tvShow)
        {
            Console.WriteLine("TvShow.Insert -> TvShow folder path: " + tvShow.FolderPath);
            var mediaItemId = await this.MediaItemRepository.GetNewMediaId(MediaType.TV_SHOW);

            await ConnectionManager.ExecuteAsync(@"
                insert into TvShows(
                    id,
                    folderPath, 
                    title, 
                    sortTitle,
                    summary, 
                    description, 
                    rating,
                    releaseYear,
                    runtimeSeconds,
                    tmdbId,
                    sourceId
                )
                values(
                    @id,
                    @folderPath,
                    @title, 
                    @sortTitle,
                    @summary,
                    @description, 
                    @rating,
                    @releaseYear,
                    @runtimeSeconds,
                    @tmdbId,
                    @sourceId
                )
            ", new
            {
                id             = mediaItemId,
                folderPath     = tvShow.FolderPath,
                title          = tvShow.Title,
                sortTitle      = tvShow.SortTitle,
                summary        = tvShow.Summary,
                description    = tvShow.Description,
                rating         = tvShow.Rating,
                releaseYear    = tvShow.ReleaseYear,
                runtimeSeconds = tvShow.RuntimeSeconds,
                tmdbId         = tvShow.TmdbId,
                sourceId       = tvShow.SourceId,
            });

            return(mediaItemId);
        }
Exemple #2
0
        public async Task <int> Update(LibGenTvShow tvShow)
        {
            using (var connection = ConnectionManager.CreateConnection())
            {
                var showId = await connection.QueryFirstOrDefaultAsync <int?>(@"
                    select id from TvShows where folderPath = @folderPath
                ", new { folderPath = tvShow.FolderPath });

                if (showId == null)
                {
                    throw new Exception($"Tv show not found in database with path {tvShow.FolderPath}");
                }
                await connection.ExecuteAsync(@"
                    update TvShows
                    set
                        folderPath = @folderPath,
                        title = @title, 
                        sortTitle = @sortTitle,
                        summary = @summary,
                        description = @description, 
                        rating = @rating,
                        releaseYear = @releaseYear,
                        runtimeSeconds = @runtimeSeconds,
                        tmdbId = @tmdbId,
                        sourceId = @sourceId
                    where id = @showId
                ", new

                {
                    folderPath     = tvShow.FolderPath,
                    title          = tvShow.Title,
                    sortTitle      = tvShow.SortTitle,
                    summary        = tvShow.Summary,
                    description    = tvShow.Description,
                    rating         = tvShow.Rating,
                    releaseYear    = tvShow.ReleaseYear,
                    runtimeSeconds = tvShow.RuntimeSeconds,
                    tmdbId         = tvShow.TmdbId,
                    sourceId       = tvShow.SourceId,
                    showId         = showId
                });

                return(showId.Value);
            }
        }