public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var languageRepo = _cacheProvider.GetAllLanguage();

            (_helper as IViewContextAware).Contextualize(ViewContext);
            output.TagName = "div";
            output.TagMode = TagMode.StartTagAndEndTag;

            var viewModel = new LanguageSelectorModel()
            {
                Name      = Name,
                Languages = new List <LanguageViewModel>(),
                SetCookieWithJavaScript = SetCookieWithJavaScript
            };

            foreach (var language in languageRepo)
            {
                viewModel.Languages.Add(new LanguageViewModel
                {
                    CultureName = language.CultureName,
                    DisplayName = language.DisplayName,
                    IsSelected  = CultureInfo.CurrentUICulture.DisplayName == language.CultureName,
                });
            }

            var partialView = "~/Components/LanguageSelector/Views/_LanguageSelectorContainer.cshtml";
            var content     = await _helper.PartialAsync(partialView, viewModel);

            output.Content.SetHtmlContent(content);
        }
Beispiel #2
0
 public JsonResult GetAllLanguage()
 {
     return(Json(_cacheProvider.GetAllLanguage()));
 }