Esempio n. 1
0
        public TvShowSegment(Guid segmentId)
        {
            _ctx = new MediaCatalogueEntities();

            _segment = (from seg in _ctx.Media_Segment
                        .Include("Media_Item")
                        .Include("TV_Presenter")
                        .Include("TV_SeriesCategory")
                        where seg.id == segmentId
                        select seg).FirstOrDefault();

            ID = segmentId;

            if (_segment != null)
            {
                var seriesId = (from sm in _ctx.TV_SeriesMedia
                                where sm.Media_Item.id == _segment.Media_Item.id
                                select sm.TV_Series.id).FirstOrDefault();

                Presenters = MediaCatalogueHelper.GetTvSeriesPresenters(seriesId, _ctx);
                Categories = MediaCatalogueHelper.GetTvSeriesCategories(seriesId, _ctx);

                Title         = _segment.Title;
                Description   = _segment.Description;
                StartOffset   = _segment.SectionOffset;
                SectionLength = _segment.SectionLength;

                if (_segment.TV_Presenter != null)
                {
                    Presenter = (from pres in Presenters
                                 where pres.ID == _segment.TV_Presenter.id
                                 select pres).FirstOrDefault();
                }

                if (_segment.TV_SeriesCategory != null)
                {
                    Category = (from cat in Categories
                                where cat.ID == _segment.TV_SeriesCategory.id
                                select cat).FirstOrDefault();
                }
            }

            IsDirty = false;
        }
Esempio n. 2
0
        public static TvShowSegment NewSegment(Guid tvShowId)
        {
            var ctx = new MediaCatalogueEntities();
            var seg = new TvShowSegment
            {
                ID          = Guid.NewGuid(),
                ParentID    = tvShowId,
                Title       = "new segment",
                Description = "enter a description for this segment."
            };

            var tvSeriesId = (from ser in ctx.TV_SeriesMedia
                              .Include("TV_Series")
                              where ser.Media_Item.id == tvShowId
                              select ser.TV_Series.id).FirstOrDefault();

            seg.Presenters = MediaCatalogueHelper.GetTvSeriesPresenters(tvSeriesId, ctx);
            seg.Categories = MediaCatalogueHelper.GetTvSeriesCategories(tvSeriesId, ctx);

            return(seg);
        }