Beispiel #1
0
        public ActionResult ShowDetails(int showId)
        {
            var showResult = _tvdb.GetShow(showId);
            var viewModel  = new ShowDetailsViewModel
            {
                Show         = showResult,
                EpisodeInfos = null
            };

            return(View(viewModel));
        }
Beispiel #2
0
        public ActionResult LoggedInShowDetails(int showId, int showInfoId)
        {
            var showResult = _tvdb.GetShow(showId);
            var viewModel  = new ShowDetailsViewModel
            {
                Show = showResult
            };

            //var allEpisodes = episodeInfoDb.All.ToList();
            //viewModel.EpisodeInfos = allEpisodes.FindAll(c => c.ShowInfoId.Equals(showInfoId)).ToList();
            viewModel.EpisodeInfos = episodeInfoDb.All.Where(c => c.ShowInfoId == showInfoId).ToList();
            var showInfo = showInfoDb.Find(showInfoId);

            viewModel.ShowInfo = showInfo;
            return(View("ShowDetails", viewModel));
        }
        public ActionResult ShowDetails(int showId)
        {
            var orderedShows   = DatabaseSession.Query <Show>().ToList().OrderBy(x => x).ToList();
            var index          = orderedShows.IndexOf(orderedShows.Single(x => x.ShowId == showId));
            var previousShowId = index > 0 ? orderedShows[index - 1].ShowId : (int?)null;
            var nextShowId     = index < orderedShows.Count - 1 ? orderedShows[index + 1].ShowId : (int?)null;

            var show = DatabaseSession.Get <Show>(showId);

            var crew   = DatabaseSession.Query <ShowCrew>().Where(x => x.Show == show).Fetch(x => x.Person).ToList();
            var cast   = DatabaseSession.Query <ShowCast>().Where(x => x.Show == show).Fetch(x => x.Person).ToList();
            var awards = DatabaseSession.Query <Award>().Where(x => x.Show == show).Fetch(x => x.Person).Fetch(x => x.AwardType).ToList();

            var relatedPhotos = DatabaseSession.Query <ShowPhoto>().Where(x => x.Show == show).Fetch(x => x.Photo).ToList();

            var otherPerformances = DatabaseSession.Query <Show>()
                                    .Where(x => x.Title == show.Title &&
                                           x.ShowId != show.ShowId)
                                    .ToList();

            var viewModel = new ShowDetailsViewModel();

            viewModel.ShowPhotoUploadControl = User.IsInRole(RoleNames.Contributor) || User.IsInRole(RoleNames.Archivist);
            viewModel.PhotoUploadLinkURL     = this.GetURL <ShowPhotosController>(c => c.Upload(showId));
            viewModel.PhotoLinkURL           = this.GetURL <ShowPhotosController>(c => c.ListShowPhotos(showId, show.Photo.PhotoId));
            viewModel.PhotoThumbnailURL      = show.Photo.GetThumbnailFileURL();
            viewModel.PhotoListLinkURL       = this.GetURL <ShowPhotosController>(c => c.ListShowPhotos(showId, null));

            viewModel.Title               = show.DisplayTitle;
            viewModel.Author              = show.Author;
            viewModel.Quarter             = show.Quarter;
            viewModel.Year                = show.Year;
            viewModel.FunFacts            = show.FunFacts;
            viewModel.Pictures            = show.Pictures;
            viewModel.Toaster             = show.Toaster;
            viewModel.PreviousShowLinkURL = previousShowId.HasValue ? this.GetURL(c => c.ShowDetails(previousShowId.Value)) : "";
            viewModel.NextShowLinkURL     = nextShowId.HasValue ? this.GetURL(c => c.ShowDetails(nextShowId.Value)) : "";

            viewModel.OtherPerformances = new OtherPerformancesTableViewModel(this.Url, otherPerformances);

            viewModel.AwardsTable = new AwardsTableViewModel(
                this.Url
                , id => this.GetURL(c => c.DeleteAward(showId, id))
                , awards)
            {
                CanEdit    = this.ControllerContext.CanEditShow(show),
                AddItemURL = this.GetURL(c => c.AddAward(showId)),
            };

            viewModel.CastRolesTable = new CastRolesTableViewModel(
                this.Url
                , id => this.GetURL(c => c.DeleteCast(showId, id))
                , cast)
            {
                CanEdit    = this.ControllerContext.CanEditShow(show),
                AddItemURL = this.GetURL(c => c.AddCast(showId)),
            };

            viewModel.CrewPositionsTable = new CrewPositionsTableViewModel(
                this.Url
                , id => this.GetURL(c => c.DeleteCrew(showId, id))
                , crew)
            {
                CanEdit    = this.ControllerContext.CanEditShow(show),
                AddItemURL = this.GetURL(c => c.AddCrew(showId)),
            };

            viewModel.PhotoCount = relatedPhotos.Count;
            viewModel.NewPhotos  = relatedPhotos
                                   .OrderByDescending(x => x.InsertedDateTime)
                                   .Where(x => x.Photo.PhotoId != show.Photo.PhotoId)
                                   .Select(x => new ShowDetailsViewModel.NewPhotoViewModel
            {
                PhotoLinkURL = this.GetURL <ShowPhotosController>(c => c.ListShowPhotos(showId, x.Photo.PhotoId)),
                PhotoTinyURL = x.Photo.GetTinyFileURL(),
            })
                                   .Take(4)
                                   .ToList();

            return(View(viewModel));
        }