Beispiel #1
0
        public async Task <IActionResult> AddTVShowSeason(Guid id, Guid show, string category, string section)
        {
            // Get Genre Details
            var genre = await _unitOfWork.TVShowControl.GetGenre(id);

            var genreName = genre.Genre;

            // Get Show Details
            var showValue = await _unitOfWork.TVShowControl.GetTVShow(show);

            var showTitle = showValue.TVShowTitle;

            // Get Values from Genre & TV Show and Display in View
            ViewBag.GenreUrl = FilePathUrlHelper.UrlString(genreName);
            ViewBag.ShowUrl  = FilePathUrlHelper.UrlString(showTitle);
            ViewBag.Genre    = genreName;
            ViewBag.Gid      = id;
            ViewBag.TVShow   = showTitle;
            ViewBag.TVShowId = show;

            SectionTVShowSubCategorySeason model = new SectionTVShowSubCategorySeason()
            {
                CategoryId = id,
                TVShowId   = show
            };

            return(View(model));
        }
Beispiel #2
0
        public async Task UpdateTVShowSeason(SectionTVShowSubCategorySeason model)
        {
            var captureModel = await _context.ClamSectionTVShowSubCategorySeasons.FindAsync(model.SeasonId);

            _context.Entry(captureModel).Entity.TVShowSeasonNumber = model.TVShowSeasonNumber;
            _context.Entry(captureModel).Entity.LastModified       = DateTime.Now;
            _context.Entry(captureModel).State = EntityState.Modified;
            _context.Update(captureModel);
            Task.WaitAll(_context.SaveChangesAsync());
        }
Beispiel #3
0
        public async Task AddTVShowSeason(Guid id, SectionTVShowSubCategorySeason model)
        {
            var showImagePath = _context.ClamSectionTVShowSubCategories.Find(model.TVShowId);
            ClamSectionTVShowSubCategorySeason result = new ClamSectionTVShowSubCategorySeason
            {
                CategoryId         = id,
                TVShowId           = model.TVShowId,
                ItemPath           = showImagePath.ItemPath,
                TVShowSeasonNumber = model.TVShowSeasonNumber
            };
            await _context.Set <ClamSectionTVShowSubCategorySeason>().AddAsync(result);

            Task.WaitAll(_context.SaveChangesAsync());
        }
Beispiel #4
0
        public async Task RemoveTVShowSeason(SectionTVShowSubCategorySeason model)
        {
            var fullDirectoryPath = string.Empty;

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("TV Show Season",
                                         $"The request couldn't be processed (Error 1).");
                // Log error
            }

            // TODO: Add delete logic here
            fullDirectoryPath = string.Format("{0}\\{1}\\{2}\\{3}",
                                              _targetFolderPath,
                                              model.CategoryId.ToString(),
                                              model.TVShowId.ToString(),
                                              model.SeasonId.ToString());

            // Completed Implementation
            var result = await _context.ClamSectionTVShowSubCategorySeasons.FindAsync(model.SeasonId);

            var collectEpisodes = _context.ClamSectionTVShowSubCategorySeasonItems.AsNoTracking();
            List <ClamSectionTVShowSubCategorySeasonItem> seasonItems = new List <ClamSectionTVShowSubCategorySeasonItem>();

            foreach (var item in collectEpisodes)
            {
                if (item.SeasonId == model.SeasonId && item.TVShowId == model.TVShowId && item.CategoryId == model.CategoryId)
                {
                    seasonItems.Add(new ClamSectionTVShowSubCategorySeasonItem()
                    {
                        ItemId     = item.ItemId,
                        CategoryId = model.CategoryId,
                        TVShowId   = model.TVShowId,
                        SeasonId   = model.SeasonId
                    });
                }
            }
            _context.Set <ClamSectionTVShowSubCategorySeasonItem>().RemoveRange(seasonItems);
            if (Directory.Exists(fullDirectoryPath))
            {
                Directory.Delete(fullDirectoryPath, true);
            }
            _context.ClamSectionTVShowSubCategorySeasons.Remove(result);
            Task.WaitAll(_context.SaveChangesAsync());
        }
Beispiel #5
0
        public async Task <IActionResult> DeleteTVShowSeason(Guid id, Guid show, Guid season, string category, string section, string subsection)
        {
            var model = await _unitOfWork.TVShowControl.GetSeason(season);

            var episodes = await _unitOfWork.TVShowControl.GetSeasonEpisodes(id, show, season);

            if (model.CategoryId == id && model.TVShowId == show && model.SeasonId == season)
            {
                SectionTVShowSubCategorySeason retrieveModel = new SectionTVShowSubCategorySeason()
                {
                    SeasonId                   = model.SeasonId,
                    TVShowSeasonNumber         = model.TVShowSeasonNumber,
                    ItemPath                   = model.ItemPath,
                    LastModified               = model.LastModified,
                    DateCreated                = model.DateCreated,
                    CategoryId                 = model.CategoryId,
                    TVShowId                   = model.TVShowId,
                    SubCategorySeasonItemCount = episodes.Episodes.Count
                };

                var genre = await _unitOfWork.TVShowControl.GetGenre(id);

                var genreName = genre.Genre;
                ViewBag.Genre    = genreName;
                ViewBag.GenreUrl = FilePathUrlHelper.UrlString(genreName);

                // Get Show Details
                var showValue = await _unitOfWork.TVShowControl.GetTVShow(show);

                var showTitle = showValue.TVShowTitle;
                ViewBag.Show         = showTitle;
                ViewBag.ShowUrl      = FilePathUrlHelper.UrlString(showTitle);
                ViewBag.SeasonId     = season;
                ViewBag.SeasonNumber = model.TVShowSeasonNumber;

                ViewBag.Gid      = model.CategoryId;
                ViewBag.TVShowId = model.TVShowId;
                ViewBag.Episodes = model.SubCategorySeasonItemList;
                return(View(retrieveModel));
            }
            return(RedirectToAction(nameof(TVShowSeasons), new { Id = id, Show = show }));
        }
Beispiel #6
0
        public async Task <IActionResult> AddTVShowSeason(Guid id, Guid show, SectionTVShowSubCategorySeason entity, string category, string section)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("TV Show Season",
                                             $"The request couldn't be processed (Error 1).");
                    // Log error

                    return(BadRequest(ModelState));
                }
                await _unitOfWork.TVShowControl.AddTVShowSeason(id, entity);

                return(RedirectToAction(nameof(TVShowSeasons), new { Id = id, Show = entity.TVShowId, Category = category, Section = section }));
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #7
0
        public async Task <IActionResult> DeleteTVShowSeason(Guid id, Guid show, Guid season, string category, string section, string subsection, SectionTVShowSubCategorySeason entity)
        {
            try
            {
                await _unitOfWork.TVShowControl.RemoveTVShowSeason(entity);

                _unitOfWork.Complete();
                return(RedirectToAction(nameof(TVShowSeasons), new { Id = id, Show = entity.TVShowId, Category = category, Section = section, Subsection = subsection }));
            }
            catch (Exception)
            {
                throw;
            }
        }