Пример #1
0
        public TvSeriesCategory(Guid categoryId)
        {
            _ctx = new MediaCatalogueEntities();

            _category = (from cat in _ctx.TV_SeriesCategory
                         where cat.id == categoryId
                         select cat).FirstOrDefault();
            ID          = _category.id;
            Title       = _category.Title;
            Description = _category.Description;
            IsDirty     = false;
        }
Пример #2
0
        protected override CommandResult Update()
        {
            if (_ctx == null)
            {
                _ctx = new MediaCatalogueEntities();
            }

            if (IsNew)
            {
                var tvSeries = (from series in _ctx.TV_Series
                                where series.id == SeriesID
                                select series).FirstOrDefault();

                // Note: Because we are attaching a Series to the SeriesCategory, the SeriesCategory
                // is automatically associated with the DataContext we are using - no need to manually add it.
                _category = new TV_SeriesCategory
                {
                    id        = this.ID,
                    TV_Series = tvSeries
                };
            }

            _category.Title       = Title;
            _category.Description = Description;

            try
            {
                _ctx.SaveChanges();
            }
            catch (Exception)
            {
                return(CommandResult.Failed);
            }

            return(CommandResult.Successful);
        }