Ejemplo n.º 1
0
        public async Task <IActionResult> MovieList()
        {
            var dbGenres = await _traktMovieRepository.GetGenres();

            var dbCertifications = await _traktMovieRepository.GetCertifications();

            var dbCountryCodes = await _traktCodesRepository.GetCountryCodes();

            var dbLanguageCodes = await _traktCodesRepository.GetLanguageCodes();

            var model = new CreateMovieListViewModel
            {
                Genres                = new MultiSelectList(dbGenres, nameof(TraktMovieGenre.Slug), nameof(TraktMovieGenre.Slug)),
                Certifications        = new MultiSelectList(dbCertifications, nameof(TraktMovieCertification.Slug), nameof(TraktMovieCertification.Description)),
                Countries             = new MultiSelectList(dbCountryCodes, nameof(CountryCode.Code), nameof(CountryCode.Name)),
                Languages             = new MultiSelectList(dbLanguageCodes, nameof(LanguageCode.Code), nameof(LanguageCode.Description)),
                Translations          = new MultiSelectList(dbLanguageCodes, nameof(LanguageCode.Code), nameof(LanguageCode.Description)),
                ReverseGenres         = new MultiSelectList(dbGenres, nameof(TraktMovieGenre.Slug), nameof(TraktMovieGenre.Name)),
                ReverseCertifications = new MultiSelectList(dbCertifications, nameof(TraktMovieCertification.Slug), nameof(TraktMovieCertification.Description)),
                ReverseCountries      = new MultiSelectList(dbCountryCodes, nameof(CountryCode.Code), nameof(CountryCode.Name)),
                ReverseLanguages      = new MultiSelectList(dbLanguageCodes, nameof(LanguageCode.Code), nameof(LanguageCode.Description)),
                ReverseTranslations   = new MultiSelectList(dbLanguageCodes, nameof(LanguageCode.Code), nameof(LanguageCode.Description))
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task Execute()
        {
            var result = await _traktClient.Certifications.GetMovieCertificationsAsync();

            if (result.IsSuccess)
            {
                var currentCertifications = await _traktMovieRepository.GetCertifications();

                foreach (var traktCertification in result.Value.US)
                {
                    var certification = currentCertifications.FirstOrDefault(x => x.Slug == traktCertification.Slug);

                    if (certification == null)
                    {
                        await _traktMovieRepository.CreateCertification(new TraktMovieCertification()
                        {
                            Name        = traktCertification.Name,
                            Description = traktCertification.Description,
                            Slug        = traktCertification.Slug
                        });
                    }
                }
            }
        }