//Plays season with episodes populated in playlist
        public ActionResult WatchSeason(int id)
        {
            MediaManagerDB           db_episodes = new MediaManagerDB();
            List <TelevisionEpisode> episodes    = db_episodes.TelevisionEpisodes.Where(e => e.fk_SeasonID == id).Where(e => e.IsEnabled.Equals(1)).ToList <TelevisionEpisode>();

            return(PartialView("_WatchSeason", episodes));
        }
Ejemplo n.º 2
0
        public ActionResult DownloadDetails(string id)
        {
            MediaManagerDB dls = new MediaManagerDB();

            var model = dls.DownloadQueues.Where(e => e.pk_torrentID == id).First();

            return(PartialView("_DownloadDetails", model));
        }
        public ActionResult EditEpisodeDetails(int id)
        {
            MediaManagerDB db_episodes = new MediaManagerDB();

            var model = db_episodes.TelevisionEpisodes.Where(e => e.pk_EpisodeID == id).Where(episode => episode.IsEnabled.Equals(1)).First();

            return(PartialView("_EditEpisode", model));
        }
        /// <summary>
        /// Action to add sort item to the database
        /// </summary>
        /// <param name="newItem">MediaManagerDBModel representing the new item to add to the database</param>
        /// <returns>
        /// redirect to view displaying kendoui grid with all sort items
        /// </returns>
        public ActionResult AddSortItem(sortItem newItem)
        {
            MediaManagerDB items = new MediaManagerDB();

            items.sortItems.Add(newItem);
            items.SaveChanges();

            return(RedirectToAction("GetContent"));
        }
        /// <summary>
        /// Create default SDN user for initial setup
        /// </summary>
        /// <param name="db">MediaManagerDB Context</param>
        public static void CreateSDNUsers(MediaManagerDB db)
        {
            List <AspNetUser> users = db.AspNetUsers.ToList <AspNetUser>();

            users.Add(new AspNetUser {
                UserName = "******", PasswordHash = "AH5XIgvyOVraK0OozwQC7wchNBbKHHhpboJgpSx2gD3ZbJgfuKZ1CJU69DcvJXDNHA==", Email = "--setup--", EmailConfirmed = false, AllowAccess = 2
            });
            db.SaveChanges();
        }
        /// <summary>
        /// Create necessary permission levels to create default SDN Media Manager roles
        /// </summary>
        /// <param name="db">DBContext connection to SQL</param>
        /// <remarks>
        /// Please note: Users may be assigned multiple permission levels and roles, the least restrictive permission usually prevails.
        /// I.E. If a user is in both the Guest and User roles, the user will have User Priviliges.  Please be aware and set permissions appropriately.
        /// </remarks>
        public static void CreateSDNPermissionLevels(MediaManagerDB db)
        {
            List <SDNPermissionLevel> defaultPermissions = new List <SDNPermissionLevel>();

            //Default Role: SuperAdmin -
            defaultPermissions.Add(new SDNPermissionLevel {
                PermissionLevelNum = 0, PermissionLevelAuth = "SUPER", PermissionLevelDisplay = "SuperAdmin"
            });

            //Default Role: Administrator - Administrators to the SDN Media Manager system, have all access to config and content
            defaultPermissions.Add(new SDNPermissionLevel {
                PermissionLevelNum = 100, PermissionLevelAuth = "ADMIN", PermissionLevelDisplay = "Administrator"
            });

            //Default Role: Content Moderator - Users who have access to add and remove content in media libraries, but no access to any other administrative configurations
            defaultPermissions.Add(new SDNPermissionLevel {
                PermissionLevelNum = 150, PermissionLevelAuth = "CONMOD", PermissionLevelDisplay = "Content Moderator"
            });

            //Default Role: Content Contributor - Users who have been granted access to add content to media libraries, but not remove or acccess any other administrative configurations
            defaultPermissions.Add(new SDNPermissionLevel {
                PermissionLevelNum = 175, PermissionLevelAuth = "CONCONT", PermissionLevelDisplay = "Content Contributor"
            });

            //Default Role: System User - Normal system user, able to watch content in media libraries, and enter requests for media
            defaultPermissions.Add(new SDNPermissionLevel {
                PermissionLevelNum = 200, PermissionLevelAuth = "USER", PermissionLevelDisplay = "System User"
            });

            //Default Role: System Gust - User who is able to test drive the look and feel of the SDN Media Manager layout, but not able to add, remove, or watch any content.  May prove useful for testing
            defaultPermissions.Add(new SDNPermissionLevel {
                PermissionLevelNum = 300, PermissionLevelAuth = "GUEST", PermissionLevelDisplay = "System Guest"
            });


            using (db)
            {
                List <list_permissionLevels> existing = db.list_permissionLevels.ToList();
                foreach (SDNPermissionLevel permission in defaultPermissions)
                {
                    if ((db.list_permissionLevels.SqlQuery($"SELECT count(permissionLevelAuth) FROM list_permissionLevels WHERE permissionLevelAuth = '{ permission.PermissionLevelAuth }' ").Count()) < 1)
                    {
                        try
                        {
                            db.list_permissionLevels.SqlQuery($"INSERT INTO list_permissionLevels ([pk_permissionLevelNum], [permissionLevelAuth], [permissionLevelDisplay]) VALUES ('{ permission.PermissionLevelNum }', '{ permission.PermissionLevelAuth }', '{ permission.PermissionLevelDisplay }') ");
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Get the Show Listing or optionally pass a show to get season details
        /// </summary>
        /// <param name="id">pk_ShowID of the show to get info on</param>
        /// <returns>
        /// List view of all shows or show details if id provided
        /// </returns>
        public ActionResult ShowInfo(int?id)
        {
            MediaManagerDB db_shows = new MediaManagerDB();

            if (string.IsNullOrEmpty(id.ToString()))
            {
                return(View(db_shows.TelevisionShows.OrderBy(show => show.ShowName)));
            }
            else
            {
                return(View(db_shows.TelevisionShows.Where(show => show.pk_ShowID.Equals(id))));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Get sum of file size of all episodes in season
        /// </summary>
        /// <param name="uSeason">Season to sum episode file sizes</param>
        /// <returns>long int total bytes of all episodes</returns>
        public static long SeasonFileSize(this TelevisionSeason uSeason)
        {
            long finalSize = 0;

            using (MediaManagerDB db = new MediaManagerDB())
            {
                foreach (TelevisionEpisode episode in (uSeason.TelevisionEpisodes))
                {
                    finalSize += episode.GetFileSize();
                }

                return(finalSize);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Get total file size of show, season, or individual episodes
        /// </summary>
        /// <param name="showName">Name of show to limit filesizes to</param>
        /// <param name="seasonNumber">Number of season to limit filesize of episodes to</param>
        /// <param name="episodeNumber">Number of single episode of which to get filesize</param>
        /// <returns>long int total filesizes in bytes</returns>
        public static long GetFileSize(string showName, int?seasonNumber, int?episodeNumber)
        {
            long finalSize = 0;

            using (MediaManagerDB db = new MediaManagerDB())
            {
                foreach (TelevisionShow show in db.TelevisionShows.Where(s => s.ShowName == showName))
                {
                    if (!seasonNumber.HasValue)
                    {
                        foreach (TelevisionSeason season in show.TelevisionSeasons)
                        {
                            foreach (TelevisionEpisode episode in season.TelevisionEpisodes)
                            {
                                FileInfo info = new FileInfo(episode.EpisodePath);

                                finalSize += info.Length;
                            }
                        }
                    }
                    else
                    {
                        foreach (TelevisionSeason season in show.TelevisionSeasons.Where(s => s.SeasonNum == seasonNumber))
                        {
                            if (!episodeNumber.HasValue)
                            {
                                foreach (TelevisionEpisode episode in season.TelevisionEpisodes)
                                {
                                    FileInfo info = new FileInfo(episode.EpisodePath);

                                    finalSize += info.Length;
                                }
                            }
                            else
                            {
                                foreach (TelevisionEpisode episode in season.TelevisionEpisodes.Where(e => e.EpisodeNum == episodeNumber))
                                {
                                    FileInfo info = new FileInfo(episode.EpisodePath);

                                    finalSize += info.Length;
                                }
                            }
                        }
                    }
                }
            }

            return(finalSize);
        }
Ejemplo n.º 10
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);

            IdentityDbContext db    = new IdentityDbContext("AppUserDB");
            MediaManagerDB    media = new MediaManagerDB();

            //create our role and user managers
            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(db));
            var userManager = new UserManager <IdentityUser>(new UserStore <IdentityUser>(db));

            //Create default SDN Media permissions, users, and roles
            //
            //SecurityAuthorization.CreateSDNPermissionLevels(media);
            //SecurityAuthorization.CreateSDNRoles(roleManager);
        }
Ejemplo n.º 11
0
 //Show view to create new season
 public ActionResult AddSeason(int?id)
 {
     using (MediaManagerDB shows_db = new MediaManagerDB())
     {
         if (id.HasValue)
         {
             TelevisionShow shows = shows_db.TelevisionShows.Where(showDetails => showDetails.pk_ShowID == id).FirstOrDefault();
             return(View(shows));
         }
         else
         {
             return(View(new TelevisionShow {
                 pk_ShowID = 0, ShowName = null, ShowHomePath = null
             }));
         }
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Deactivates the show in the SDN Media Manager disallowing it from being searched and watched
        /// </summary>
        /// <param name="showID">Model of show to deactivate</param>
        /// <param name="conn">DBContext connection to use to deactivate show</param>
        /// <returns>true if deactivated successfully</returns>
        public static bool DeactivateShow(int showID, MediaManagerDB conn)
        {
            bool finalResult;

            using (conn)
            {
                var db = conn.DeactivateShow(showID);

                if (db == 1)
                {
                    finalResult = true;
                }
                else
                {
                    finalResult = false;
                }
            }

            return(finalResult);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Activates the show in the SDN Media Manager allowing it to be searched and watched
        /// </summary>
        /// <param name="show">Model of show to activate</param>
        /// <param name="conn">DBContext connection to use to activate show</param>
        /// <returns>true if activated successfully</returns>
        public static bool ActivateShow(this TelevisionShow show, MediaManagerDB conn)
        {
            bool finalResult;

            using (conn)
            {
                var db = conn.ActivateShow(show.pk_ShowID);

                if (db == 1)
                {
                    finalResult = true;
                }
                else
                {
                    finalResult = false;
                }
            }

            return(finalResult);
        }
Ejemplo n.º 14
0
        public ActionResult CreateShow([Bind(Include = "pk_ShowID,ShowName,ShowDriveLetter,ShowHomePath,ShowNumSeasons,ShowNumEpisodes,ShowAlbumArtPath,IsEnabled,TvdbID,ImdbID,fk_MediaType")] TelevisionShow televisionShow)
        {
            MediaManagerDB db = new MediaManagerDB();

            if (ModelState.IsValid)
            {
                televisionShow.ShowAlbumArtPath = televisionShow.ShowAlbumArtPath.Replace("~art", televisionShow.ShowHomePath + @"\art");
                televisionShow.ShowNumSeasons   = 0;
                televisionShow.ShowNumEpisodes  = 0;
                televisionShow.ShowDriveLetter  = televisionShow.ShowHomePath[0].ToString();

                db.TelevisionShows.Add(televisionShow);
                db.SaveChanges();

                //var showID = db.TelevisionShows.Where(s => s.ShowName == televisionShow.ShowName).First().pk_ShowID;

                int.TryParse(db.GetShowIdByName(televisionShow.ShowName, null).ToString(), out int showID);

                return(RedirectToAction("SeasonInfo", "Media", new { id = showID }));
            }
            return(View(televisionShow));
        }
        public ActionResult ServerFiltering_GetShows(string searchTerm)
        {
            using (var shows_db = new MediaManagerDB())
            {
                var shows = shows_db.TelevisionShows.Select(show => new TelevisionShow
                {
                    pk_ShowID       = show.pk_ShowID,
                    ShowName        = show.ShowName,
                    ShowNumSeasons  = show.ShowNumSeasons,
                    ShowNumEpisodes = show.ShowNumEpisodes,
                    ShowDriveLetter = show.ShowDriveLetter,
                    ShowHomePath    = show.ShowHomePath
                });

                if (!string.IsNullOrEmpty(searchTerm))
                {
                    shows = shows.Where(s => s.ShowName.Contains(searchTerm));
                }

                return(Json(shows, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Get total file size of all show episodes
        /// </summary>
        /// <param name="uShow">Show to sum episode file sizes</param>
        /// <param name="seasonNumber">optional season number to limit sum of episode filesizes to</param>
        /// <param name="episodeNumber">optional number of single episode of which to get filesize</param>
        /// <returns>long int total bytes of all episodes for show</returns>
        public static long ShowFileSize(this TelevisionShow uShow, int?seasonNumber, int?episodeNumber)
        {
            long finalSize = 0;

            using (MediaManagerDB db = new MediaManagerDB())
            {
                foreach (TelevisionShow show in db.TelevisionShows.Where(s => s.ShowName == uShow.ShowName))
                {
                    if (!seasonNumber.HasValue)
                    {
                        foreach (TelevisionSeason season in show.TelevisionSeasons)
                        {
                            finalSize += season.SeasonFileSize();
                        }
                    }
                    else
                    {
                        foreach (TelevisionSeason season in show.TelevisionSeasons.Where(s => s.SeasonNum == seasonNumber))
                        {
                            if (!episodeNumber.HasValue)
                            {
                                finalSize += season.SeasonFileSize();
                            }
                            else
                            {
                                foreach (TelevisionEpisode episode in season.TelevisionEpisodes.Where(e => e.EpisodeNum == episodeNumber))
                                {
                                    finalSize += GetFileSize(episode.EpisodePath);
                                }
                            }
                        }
                    }
                }
            }

            return(finalSize);
        }
Ejemplo n.º 17
0
        //This is where Movie related actions will go

        #endregion

        #region Sort Actions / Views...

        /// <summary>
        /// Displays view with form for adding new sort item to the database
        /// </summary>
        /// <returns>form for adding a new sort item</returns>
        public ActionResult AddSortItem()
        {
            MediaManagerDB items = new MediaManagerDB();

            return(View());
        }
Ejemplo n.º 18
0
        public ActionResult GetDownloads()
        {
            MediaManagerDB dls = new MediaManagerDB();

            return(View(dls.DownloadQueues));
        }
Ejemplo n.º 19
0
        public ActionResult EpisodeDetails(int id)
        {
            MediaManagerDB db_episodes = new MediaManagerDB();

            return(View(db_episodes.TelevisionEpisodes.Where(e => e.pk_EpisodeID == id).Where(episode => episode.IsEnabled.Equals(1)).First()));
        }
Ejemplo n.º 20
0
        public ActionResult EpisodeInfo(int id)
        {
            MediaManagerDB db_episodes = new MediaManagerDB();

            return(View(db_episodes.TelevisionEpisodes.Where(episodes => episodes.fk_SeasonID == id).OrderBy(o => o.EpisodeNum).Where(episode => episode.IsEnabled.Equals(1))));
        }
Ejemplo n.º 21
0
        //Lists all seasons of the show who's id is passed
        public ActionResult SeasonInfo(int id)
        {
            MediaManagerDB db = new MediaManagerDB();

            return(View(db.TelevisionSeasons.Where(s => s.fk_ShowID == id).ToList <TelevisionSeason>()));
        }