示例#1
0
        public IActionResult Edit(EditMovieListViewModel vm)
        {
            var list = this.mapper.Map <MovieList>(vm);

            this.listService.Edit(list, this.User.Identity.Name);

            return(this.RedirectToAction(nameof(this.Index)));
        }
示例#2
0
        public async Task <IActionResult> EditMovieList(EditMovieListViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var list = await _traktService.Get(model.Id);

            if (list == null)
            {
                return(RedirectToAction(nameof(Lists)));
            }
            if (list.Type != ListType.Movie)
            {
                return(RedirectToAction(nameof(Lists)));
            }

            if (list.Owner.UserName == User.Identity.Name)
            {
                list.Name                               = model.Name;
                list.Query                              = model.Query ?? "";
                list.SearchByAlias                      = model.SearchByAlias;
                list.SearchByBiography                  = model.SearchByBiography;
                list.SearchByDescription                = model.SearchByDescription;
                list.SearchByName                       = model.SearchByName;
                list.SearchByOverview                   = model.SearchByOverview;
                list.SearchByPeople                     = model.SearchByPeople;
                list.SearchByTitle                      = model.SearchByTitle;
                list.SearchByTranslations               = model.SearchByTranslations;
                list.SearchByTagline                    = model.SearchByTagline;
                list.Filter_Years                       = model.Filter_Years;
                list.Filter_Runtimes                    = model.Filter_Runtimes;
                list.Filter_Ratings                     = model.Filter_Ratings;
                list.Filter_Genres                      = new GenresCommonFilter(model.Filter_Genres);
                list.Filter_Languages                   = new LanguagesCommonFilter(model.Filter_Languages);
                list.Filter_Translations                = new TranslationsBasicFilter(model.Filter_Translations);
                list.Filter_Certifications_Movie        = new CertificationsMovieFilter(model.Filter_Certifications);
                list.Filter_Countries                   = new CountriesCommonFilter(model.Filter_Countries);
                list.ReverseFilter_Genres               = new GenresCommonFilter(model.ReverseFilter_Genres);
                list.ReverseFilter_Languages            = new LanguagesCommonFilter(model.ReverseFilter_Languages);
                list.ReverseFilter_Translations         = new TranslationsBasicFilter(model.ReverseFilter_Translations);
                list.ReverseFilter_Certifications_Movie = new CertificationsMovieFilter(model.ReverseFilter_Certifications);
                list.ReverseFilter_Countries            = new CountriesCommonFilter(model.ReverseFilter_Countries);

                await _traktService.Update(list);

                return(RedirectToAction(nameof(EditMovieList), new { list.Id }));
            }

            return(RedirectToAction(nameof(Lists)));
        }
示例#3
0
        public async Task <IActionResult> EditMovieList(EditMovieListViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var list = await _traktRepository.Get(model.Id);

            if (list == null)
            {
                return(RedirectToAction(nameof(My)));
            }
            if (list.Type != ListType.Movie)
            {
                return(RedirectToAction(nameof(My)));
            }

            if (list.Owner.UserName == User.Identity.Name)
            {
                var forceRefresh = list.Name != model.Name;

                list.Name                        = model.Name;
                list.Query                       = model.Query ?? "";
                list.ContentType                 = ListContentType.Filters;
                list.SearchByAlias               = model.SearchByAlias;
                list.SearchByBiography           = model.SearchByBiography;
                list.SearchByDescription         = model.SearchByDescription;
                list.SearchByName                = model.SearchByName;
                list.SearchByOverview            = model.SearchByOverview;
                list.SearchByPeople              = model.SearchByPeople;
                list.SearchByTitle               = model.SearchByTitle;
                list.SearchByTranslations        = model.SearchByTranslations;
                list.SearchByTagline             = model.SearchByTagline;
                list.Filter_Years                = model.Filter_Years;
                list.Filter_Runtimes             = model.Filter_Runtimes;
                list.Filter_Ratings_Trakt        = model.Filter_Ratings_Trakt;
                list.Filter_Ratings_IMDb         = model.Filter_Ratings_IMDb;
                list.Filter_Genres               = new GenresCommonFilter(model.Filter_Genres);
                list.Filter_Languages            = new LanguagesCommonFilter(model.Filter_Languages);
                list.Filter_Translations         = new TranslationsBasicFilter(model.Filter_Translations);
                list.Filter_Certifications_Movie = new CertificationsMovieFilter(model.Filter_Certifications);
                list.Filter_Countries            = new CountriesCommonFilter(model.Filter_Countries);

                if (list.Owner.IsDonor)
                {
                    list.ExclusionFilter_Genres               = new GenresCommonFilter(model.ExclusionFilter_Genres);
                    list.ExclusionFilter_Languages            = new LanguagesCommonFilter(model.ExclusionFilter_Languages);
                    list.ExclusionFilter_Translations         = new TranslationsBasicFilter(model.ExclusionFilter_Translations);
                    list.ExclusionFilter_Certifications_Movie = new CertificationsMovieFilter(model.ExclusionFilter_Certifications);
                    list.ExclusionFilter_Countries            = new CountriesCommonFilter(model.ExclusionFilter_Countries);
                    list.ExclusionFilter_Keywords             = string.IsNullOrEmpty(model.ExclusionFilter_Keywords) ? null : model.ExclusionFilter_Keywords.Split(",");
                }

                try
                {
                    await _traktService.Update(list);
                }
                catch (TraktBadGatewayException)
                {
                    return(View("TraktBadGatewayException"));
                }

                await _traktRepository.Update(list);

                if (list.ScanState == ScanState.None)
                {
                    _backgroundJobQueueService.Queue(list, forceRefresh: forceRefresh);
                }


                return(RedirectToAction(nameof(EditMovieList), new { list.Id }));
            }

            return(RedirectToAction(nameof(My)));
        }