Exemplo n.º 1
0
        public async Task <IActionResult> ShowList()
        {
            ViewData["Message"] = "Create a new list for shows";

            var dbGenres = await _traktShowRepository.GetGenres();

            var dbStatus = await _traktShowRepository.GetStatuses();

            var dbNetworks = await _traktShowRepository.GetNetworks();

            var dbCertifications = await _traktShowRepository.GetCertifications();

            var dbCountryCodes = await _traktCodesRepository.GetCountryCodes();

            var dbLanguageCodes = await _traktCodesRepository.GetLanguageCodes();

            var model = new CreateShowListViewModel
            {
                Genres                = new MultiSelectList(dbGenres, nameof(TraktShowGenre.Slug), nameof(TraktShowGenre.Name)),
                Certifications        = new MultiSelectList(dbCertifications, nameof(TraktShowCertification.Slug), nameof(TraktShowCertification.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)),
                Networks              = new MultiSelectList(dbNetworks, nameof(TraktShowNetwork.Name), nameof(TraktShowNetwork.Name)),
                Status                = new MultiSelectList(dbStatus, nameof(TraktShowStatus.Name), nameof(TraktShowStatus.Name)),
                ReverseGenres         = new MultiSelectList(dbGenres, nameof(TraktShowGenre.Slug), nameof(TraktShowGenre.Name)),
                ReverseCertifications = new MultiSelectList(dbCertifications, nameof(TraktShowCertification.Slug), nameof(TraktShowCertification.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)),
                ReverseNetworks       = new MultiSelectList(dbNetworks, nameof(TraktShowNetwork.Name), nameof(TraktShowNetwork.Name)),
                ReverseStatus         = new MultiSelectList(dbStatus, nameof(TraktShowStatus.Name), nameof(TraktShowStatus.Name)),
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task Execute()
        {
            var result = await _traktClient.Genres.GetShowGenresAsync();

            if (result.IsSuccess)
            {
                var currentGenres = await _traktShowRepository.GetGenres();

                foreach (var traktGenre in result.Value)
                {
                    var currentGenre = currentGenres.FirstOrDefault(x => x.Slug != traktGenre.Slug);

                    if (currentGenre == null)
                    {
                        await _traktShowRepository.CreateGenre(new TraktShowGenre()
                        {
                            Name = traktGenre.Name,
                            Slug = traktGenre.Slug
                        });
                    }
                }
            }
        }