public void TestAddQuoteToTvShow() { AddTvShows(1); MediaLibContainer context = ContextHelper <MediaLibContainer> .GetCurrentContext(); TV_Show tvshow = context.MediaSet.OfType <TV_Show>().First <TV_Show>(); int expectedTvShowId = tvshow.Id; QuoteController quoteController = new QuoteController(); FormCollection collection = new FormCollection(); collection["Language"] = QuoteLanguageEnum.Deutsch.ToString(); collection["Character"] = "Rolle"; collection["Wann"] = "00:11:09"; collection["QuoteString"] = "QuoteStringTvShow"; ViewResult result = quoteController.AddQuote(tvshow.Id, collection, fakeUser) as ViewResult; TV_Show tvshows = MediaService.Instance.GetTvShowById(tvshow.Id); Assert.IsNotNull(tvshows); Assert.AreEqual(collection["Language"], tvshows.Quote.Single <Quote>().Language); Assert.AreEqual(collection["Character"], tvshows.Quote.Single <Quote>().Character); Assert.AreEqual(collection["Wann"], tvshows.Quote.Single <Quote>().OccurenceTime); Assert.AreEqual(collection["QuoteString"], tvshows.Quote.Single <Quote>().QuoteString); Assert.AreEqual("AddQuoteMessage", result.ViewName); }
public void TestAddTvShowToMedia() { AddTvShows(1); MediaLibContainer context = ContextHelper <MediaLibContainer> .GetCurrentContext(); TV_Show show = context.MediaSet.OfType <TV_Show>().First <TV_Show>(); int expectedShowId = show.Id; MediaController mediaController = new MediaController(); FormCollection collection = new FormCollection(); collection["ctl00$MainContent$TvShowTitle"] = show.Title; collection["ctl00$MainContent$TvShowTitleOriginal"] = show.OriginalTitle; collection["GenreList"] = show.Genre; collection["ctl00$MainContent$DatepickerBeginning"] = show.ShowBeginning.ToShortDateString(); if (show.ShowEnding != null) { collection["ctl00$MainContent$DatepickerEnding"] = show.ShowEnding.Value.ToShortDateString(); } collection["SeasonList"] = show.Season.Count.ToString(); ViewResult result = mediaController.AddTvShowToDb(collection, fakeUser) as ViewResult; TV_Show s = MediaService.Instance.GetTvShowById(show.Id); addedMedia.Add(s); Assert.IsNotNull(s); Assert.AreEqual(expectedShowId, s.Id); }
public void GetUserVideoByVideoIdShouldReturnThreeUserVideos() { MediaLibContainer context = ContextHelper <MediaLibContainer> .GetCurrentContext(); User user = context.UserSet.First <User>(); TV_Show tv_Show = TestUtil.generateTV_Show(false); UserTV_Show userTV_Show1 = TestUtil.generateUserTV_Show(new Season { Number = 1, TV_Show = tv_Show }); userTV_Show1.User = user; AddUserMedia(userTV_Show1); UserTV_Show userTV_Show2 = TestUtil.generateUserTV_Show(new Season { Number = 2, TV_Show = tv_Show }); userTV_Show2.User = user; AddUserMedia(userTV_Show2); UserTV_Show userTV_Show3 = TestUtil.generateUserTV_Show(new Season { Number = 3, TV_Show = tv_Show }); userTV_Show3.User = user; AddUserMedia(userTV_Show3); IQueryable <UserTV_Show> userTV_Shows = userTvShowDao.GetUserTvShowByTvShowId(user.Username, tv_Show.Id); Assert.AreEqual(3, userTV_Shows.Count <UserTV_Show>()); }
public void TestAddTvShowToUserMedien() { AddTvShows(1); MediaLibContainer context = ContextHelper <MediaLibContainer> .GetCurrentContext(); TV_Show tv_show = context.MediaSet.OfType <TV_Show>().First <TV_Show>(); int expectedVideoId = tv_show.Id; MediathekController mediathekController = new MediathekController(); FormCollection collection = new FormCollection(); collection["Season"] = "1"; collection["Status"] = UserMediaStatusEnum.Verborgt.ToString(); collection["Storage"] = MediaAufberwahrungsortEnum.Keller.ToString(); collection["Device"] = UserMediaStorageDeviceEnum.Dvd.ToString(); ViewResult result = mediathekController.AddTvShow(collection, fakeUser) as ViewResult; IQueryable <UserTV_Show> userVideos = UserMediaService.Instance.GetUserTvShowByIdAndUserName(fakeUser.Identity.Name, tv_show.Id); addedUserMedia.Add(userVideos.Single <UserTV_Show>()); Assert.IsNotNull(userVideos); Assert.AreEqual(expectedVideoId, userVideos.Single <UserTV_Show>().Season.TV_ShowId); Assert.AreEqual(Convert.ToInt32(collection["Season"]), userVideos.Single <UserTV_Show>().Season.Number); Assert.AreEqual(collection["Storage"], userVideos.Single <UserTV_Show>().StoragePlace); Assert.AreEqual(collection["Device"], userVideos.Single <UserTV_Show>().StorageType); }
public ActionResult AddTvShowToDb(FormCollection collection, IPrincipal user) { string title = collection["ctl00$MainContent$TvShowTitle"]; string originalTitle = collection["ctl00$MainContent$TvShowTitleOriginal"]; string genre = collection["GenreList"]; string dateBeginning = collection["ctl00$MainContent$DateTextBoxBeginning"]; string dateEnding = collection["ctl00$MainContent$DateTextBoxEnding"]; int seasons = Int32.Parse(collection["SeasonList"]); DateTime showBeginning = DateTime.MaxValue; DateTime?showEnding = null; try { if (dateBeginning.Length == 4) { DateTime year = new DateTime(Int32.Parse(dateBeginning), 01, 01); showBeginning = year; } else { showEnding = DateTime.Parse(dateEnding); } } catch (Exception) { } TV_Show show = new TV_Show(); show.Genre = genre; show.OriginalTitle = originalTitle; show.Pending = true; for (int i = 0; i < seasons; i++) { Season tvSeason = new Season(); tvSeason.Number = i + 1; show.Season.Add(tvSeason); Episode dummyEpisode = new Episode(); dummyEpisode.Name = "E01"; dummyEpisode.Number = 1; tvSeason.Episode.Add(dummyEpisode); } show.ShowBeginning = showBeginning; show.ShowEnding = showEnding; show.Title = title; show.AddingDate = DateTime.Now; InsertRequest request = new InsertRequest(); request.RequestDate = DateTime.Now; request.Media = show; request.User = MembershipService.Instance.GetCurrentUser(user.Identity.Name); MediaService.Instance.AddTvShow(show); return(View("ConfirmationAddedMedia")); }
public PartialViewResult TvShowDetails(int mediaId) { //TheMovieDB.TmdbAPI api = new TheMovieDB.TmdbAPI( //TheMovieDB.TmdbMovie movie = new TheMovieDB.TmdbMovie(); TV_Show show = MediaService.Instance.GetTvShowById(mediaId); return(PartialView("TvShowDetails", show)); }
public void GetUserVideoByVideoIdShouldReturnNoUserVideosBecauseNoSuchUsername() { TV_Show tv_Show = TestUtil.generateTV_Show(false); IQueryable <UserTV_Show> userTV_Shows = userTvShowDao.GetUserTvShowByTvShowId("nosuchusername", tv_Show.Id); Assert.AreEqual(0, userTV_Shows.Count <UserTV_Show>()); }
public void GetUserVideoByVideoIdShouldReturnNoUserVideos() { MediaLibContainer context = ContextHelper <MediaLibContainer> .GetCurrentContext(); User user = context.UserSet.First <User>(); TV_Show tv_Show = TestUtil.generateTV_Show(false); IQueryable <UserTV_Show> userTV_Shows = userTvShowDao.GetUserTvShowByTvShowId(user.Username, tv_Show.Id); Assert.AreEqual(0, userTV_Shows.Count <UserTV_Show>()); }
protected void AddTvShows(int count) { MediaLibContainer context = ContextHelper <MediaLibContainer> .GetCurrentContext(); for (int i = 1; i <= count; i++) { TV_Show tvShows = TestUtil.generateTV_Show(true); context.MediaSet.AddObject(tvShows); } context.SaveChanges(); }
public ActionResult ConfirmRequestTVShow(int id, FormCollection formCollection, IPrincipal admin) { if (!membershipService.IsAdmin(admin.Identity.Name)) { return(View("NotAuthorized")); } InsertRequest insertRequest = insertRequestService.GetById(id); if (insertRequest == null) { return(View("NotFound")); } TV_Show tv_show = insertRequest.Media as TV_Show; if (tv_show == null) { return(View("NotFound")); } int seasonsForm = 0; try { seasonsForm = Convert.ToInt32(formCollection["Seasons"]); } catch (Exception) { ViewData.ModelState.AddModelError("Seasons", ""); } if (seasonsForm > 100) { seasonsForm = 0; ViewData.ModelState.AddModelError("Seasons", ""); } if (TryUpdateModel <TV_Show>(tv_show)) { if (seasonsForm > 0) { UpdateSeasons(tv_show, seasonsForm - tv_show.Season.Count); tv_show.Pending = false; insertRequestService.Delete(insertRequest); insertRequestService.Save(); return(RedirectToAction("MediaRequests")); } } return(View("MediaRequests", CreateErrorRequest(insertRequest))); }
public ActionResult TVShow(string username, int id) { TV_Show tvshow = MediaService.Instance.GetTvShowById(id); if (tvshow == null) { return(View("NotFound")); } IQueryable <UserTV_Show> userTVShows; TVShowDetailsViewModel tvshowDetails; Image image = null; try { image = imageService.GetImagesForVideo(tvshow)[AWSImageService.MEDIUMIMAGE]; } catch (Exception) {} if (image == null) { image = AWSImageService.IMAGE_NOIMAGEFOUND; } if (User.Identity.IsAuthenticated) { if (User.Identity.Name.Equals(username) || username == null) { userTVShows = UserMediaService.Instance.GetUserTvShowByIdAndUserName(User.Identity.Name, id); tvshowDetails = new TVShowDetailsViewModel(tvshow, image, userTVShows, MembershipService.Instance.GetCurrentUser(User.Identity.Name)); } else if (MembershipService.Instance.GetCurrentUser(User.Identity.Name).Friends.Contains(MembershipService.Instance.GetCurrentUser(username))) { userTVShows = UserMediaService.Instance.GetUserTvShowByIdAndUserName(username, id); tvshowDetails = new TVShowDetailsViewModel(tvshow, image, userTVShows, MembershipService.Instance.GetCurrentUser(username)); } else if (!MembershipService.Instance.GetCurrentUser(User.Identity.Name).Friends.Contains(MembershipService.Instance.GetCurrentUser(username))) { userTVShows = UserMediaService.Instance.GetUserTvShowByIdAndUserName(User.Identity.Name, id); tvshowDetails = new TVShowDetailsViewModel(tvshow, image, userTVShows, MembershipService.Instance.GetCurrentUser(User.Identity.Name)); } else { tvshowDetails = new TVShowDetailsViewModel(tvshow, image); } } else { tvshowDetails = new TVShowDetailsViewModel(tvshow, image); } return(View("TVShowDetails", tvshowDetails)); }
public ActionResult AddActorTvShow(FormCollection collection, int id) { TV_Show video = MediaService.Instance.GetTvShowById(id); string name = collection["Persons"]; Actor actor = PersonService.Instance.GetActor(name).Single(); if (!video.Actor.Contains(actor)) { video.Actor.Add(actor); MediaService.Instance.SaveChangesTvShow(); } return(RedirectToAction("TVShow", new { id = id })); }
private void InitializeTV() { TV_Show.BeginUpdate(); foreach (MyFolder driver in browser.Folders) { TreeNode node = new TreeNode(driver.Name); node.Tag = driver; TV_Show.Nodes.Add(node); foreach (MyFolder folder in driver.Folders) { TreeNode f_node = new TreeNode(folder.Name); f_node.Tag = folder; node.Nodes.Add(f_node); } } //DriveInfo[] allDrives = DriveInfo.GetDrives(); //int i = 0; //foreach (DriveInfo d in allDrives) //{ // TV_Show.Nodes.Add(d.Name); // DirectoryInfo di = new DirectoryInfo(d.Name); // try // { // if (d.IsReady) // { // foreach (var dirf in di.GetFileSystemInfos()) // { // TV_Show.Nodes[i].Nodes.Add(dirf.Name); // } // } // i++; // } // catch (Exception) // { // throw new Exception(); // } //} TV_Show.EndUpdate(); }
private void TV_Show_AfterExpand(object sender, TreeViewEventArgs e) { TV_Show.BeginUpdate(); //MyFolder folder = e.Node.Tag as MyFolder; //folder.innerFolders(); //foreach (MyFolder f in folder.Folders) //{ // if(f.Folders == null) // { // f.innerFolders(); // } //} MyFolder me = e.Node.Tag as MyFolder; me.innerFolders(); foreach (TreeNode f in e.Node.Nodes)//sons { foreach (var sub in (f.Tag as MyFolder).Folders) { TreeNode t = new TreeNode(sub.Name); t.Tag = sub; f.Nodes.Add(t); } } //foreach (TreeNode s in e.Node.Nodes) //{ // try // { // DirectoryInfo di = new DirectoryInfo(s.FullPath); // foreach (var st in di.GetFileSystemInfos()) // { // s.Nodes.Add(st.Name); // } // } // catch (Exception) // { // } //} TV_Show.EndUpdate(); }
public static QuoteTV_Show generateQuoteTV_Show() { QuoteTV_Show quoteTV_Show = new QuoteTV_Show(); quoteTV_Show.QuoteString = "quoteString"; quoteTV_Show.Language = "English"; quoteTV_Show.Character = "T-1000"; quoteTV_Show.Ranking = 1; TV_Show tv_show = generateTV_Show(true); Episode episode = tv_show.Season.First <Season>().Episode.First <Episode>(); quoteTV_Show.Episode = episode; quoteTV_Show.Media = tv_show; return(quoteTV_Show); }
public ActionResult DeleteTvShow(int id, IPrincipal user) { UserTV_Show userTvShow = userMediaService.GetTvShowById(id); if (userTvShow == null) { return(View("NotFound")); } TV_Show tvShow = userTvShow.Season.TV_Show; if (userTvShow.User.Username != user.Identity.Name) { return(View("NotAuthorized")); } userMediaService.DeleteTvShow(userTvShow); return(RedirectToAction("TVShow", "Media", new { id = tvShow.Id })); }
protected static void CreateTestContext() { using (MediaLibContainer context = new MediaLibContainer()) { user = new User(); user.Username = "******"; user.Password = "******"; book = TestUtil.generateBook(); movie = TestUtil.generateMovie(); tv_Show = TestUtil.generateTV_Show(false); context.UserSet.AddObject(user); context.MediaSet.AddObject(book); context.MediaSet.AddObject(movie); context.MediaSet.AddObject(tv_Show); context.SaveChanges(); } fakeUser = new GenericPrincipal(new GenericIdentity(user.Username, "Forms"), null); }
public static TV_Show generateTV_Show(bool withEpisode) { TV_Show tv_show = new TV_Show(); tv_show.Title = "TV_Show_Title"; tv_show.OriginalTitle = "TV_Show_OrignialTitle"; tv_show.ShowBeginning = new DateTime(1999, 1, 1); tv_show.AddingDate = DateTime.Now; if (withEpisode) { Season season = new Season(); season.Number = 1; season.TV_Show = tv_show; Episode episode = new Episode(); episode.Name = "testepisode"; episode.Season = season; } return(tv_show); }
public ActionResult MediaDetails(int mediaId, string mediaType) { if (typeof(Movie).Name == mediaType) { Movie movie = MediaService.Instance.GetMovieById(mediaId); return(RedirectToAction("Movie", "Media", new { id = movie.Id })); } else if (typeof(Book).Name == mediaType) { Book book = MediaService.Instance.GetBookById(mediaId); return(RedirectToAction("Book", "Media", new { id = book.Id })); } else if (typeof(TV_Show).Name == mediaType) { TV_Show tv_show = MediaService.Instance.GetTvShowById(mediaId); return(RedirectToAction("TVShow", "Media", new { id = tv_show.Id })); } else { throw new ArgumentException(); } }
private void UpdateSeasons(TV_Show tv_show, int diff) { if (diff == 0) { return; } IQueryable <Season> seasons = from season in tv_show.Season.AsQueryable <Season>() orderby season.Number select season; if (diff < 0) { IQueryable <Season> newSeason = seasons.Skip <Season>(tv_show.Season.Count + diff); foreach (Season season in newSeason) { mediaService.DeleteSeason(season); } } if (diff > 0) { int last = seasons.Last <Season>().Number; int count = seasons.Count <Season>() + diff; for (last++; last <= count; last++) { Season s = new Season(); s.Number = last; s.TV_Show = tv_show; tv_show.Season.Add(s); } } }
public ActionResult AddQuote(int id, FormCollection collection, IPrincipal iuser) { User user = MembershipDao.Instance.GetCurrentUser(iuser.Identity.Name); Book book = MediaService.Instance.GetBookById(id); if (book != null) { QuoteBook quoteBook = new QuoteBook(); quoteBook.Language = collection["Language"]; quoteBook.Character = collection["Character"]; quoteBook.QuoteString = collection["QuoteString"]; quoteBook.MediaId = id; quoteBook.UserId = user.Id; quoteBook.Book = book; quoteService.AddQuote(quoteBook); } Movie movie = MediaService.Instance.GetMovieById(id); if (movie != null) { QuoteMovie quoteMovie = new QuoteMovie(); quoteMovie.Language = collection["Language"]; quoteMovie.Character = collection["Character"]; quoteMovie.OccurenceTime = collection["Wann"]; quoteMovie.QuoteString = collection["QuoteString"]; quoteMovie.MediaId = id; quoteMovie.UserId = user.Id; quoteMovie.Movie = movie; quoteService.AddQuote(quoteMovie); } TV_Show tvshow = MediaService.Instance.GetTvShowById(id); if (tvshow != null) { QuoteTV_Show quoteTVShow = new QuoteTV_Show(); quoteTVShow.Language = collection["Language"]; quoteTVShow.Character = collection["Character"]; quoteTVShow.OccurenceTime = collection["Wann"]; quoteTVShow.QuoteString = collection["QuoteString"]; quoteTVShow.MediaId = id; quoteTVShow.UserId = user.Id; Season season = MediaService.Instance.GetSeasonById(tvshow.Season.ElementAt <Season>(0).Id); Episode episode = new Episode(); episode.Name = season.Episode.ElementAt <Episode>(0).Name; episode.Number = season.Episode.ElementAt <Episode>(0).Number; episode.Season = season; quoteTVShow.Episode = episode; quoteService.AddQuote(quoteTVShow); } //return View("ShowQuotesMedia", quotes); //return RedirectToAction("ShowQuotesMedia", "Quote", new { mediaId = id }); return(View("AddQuoteMessage")); }
public ActionResult Rating(int id, double rating) { ViewData["message"] = "Ihre Bewertung wurde erfolgreich gespeichert."; int idn = Convert.ToInt32(id); Book book = MediaService.Instance.GetBookById(idn); if (book != null) { if (CanUserVote(idn, Convert.ToInt32(rating)) == true) { book.TotalRaters = book.TotalRaters + 1; book.Rating += Convert.ToInt32(rating); book.AverageRating = book.Rating / book.TotalRaters; MediaService.Instance.SaveChangesBook(); ViewData["message"] = "Ihre Bewertung dieses Buches wurde erfolgreich gespeichert."; } else { book.Rating -= userRating(idn); book.Rating += Convert.ToInt32(rating); book.AverageRating = book.Rating / book.TotalRaters; MediaService.Instance.SaveChangesBook(); ViewData["message"] = "Ihre Bewertung dieses Buches wurde erfolgreich aktualisiert."; } } Movie movie = MediaService.Instance.GetMovieById(idn); if (movie != null) { if (CanUserVote(idn, Convert.ToInt32(rating)) == true) { movie.TotalRaters = movie.TotalRaters + 1; movie.Rating += Convert.ToInt32(rating); movie.AverageRating = movie.Rating / movie.TotalRaters; MediaService.Instance.SaveChangesMovie(); ViewData["message"] = "Ihre Bewertung dieses Films wurde erfolgreich gespeichert."; } else { movie.Rating -= userRating(idn); movie.Rating += Convert.ToInt32(rating); movie.AverageRating = movie.Rating / movie.TotalRaters; MediaService.Instance.SaveChangesMovie(); ViewData["message"] = "Ihre Bewertung dieses Films wurde erfolgreich aktualisiert."; } } TV_Show tv_show = MediaService.Instance.GetTvShowById(idn); if (tv_show != null) { if (CanUserVote(idn, Convert.ToInt32(rating)) == true) { tv_show.TotalRaters = tv_show.TotalRaters + 1; tv_show.Rating += Convert.ToInt32(rating); tv_show.AverageRating = tv_show.Rating / tv_show.TotalRaters; MediaService.Instance.SaveChangesTvShow(); ViewData["message"] = "Ihre Bewertung dieser TV-Serie wurde erfolgreich gespeichert."; } else { tv_show.Rating -= userRating(idn); tv_show.Rating += Convert.ToInt32(rating); tv_show.AverageRating = tv_show.Rating / tv_show.TotalRaters; MediaService.Instance.SaveChangesTvShow(); ViewData["message"] = "Ihre Bewertung dieser TV-Serie wurde erfolgreich aktualisiert."; } } return(View()); }