Пример #1
0
            public async Task <Result <LanguageVM[]> > Handle(GetSupportedLanguagesQuery request, CancellationToken cancellationToken)
            {
                await Task.Yield();

                return(_cultureService.GetSupportedLanguages().Values
                       .Select(s => new LanguageVM(s.key, s.caption))
                       .ToArray());
            }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            await Task.Yield();

            var lang             = _cultureService.GetCurrentCulture();
            var key              = lang.Length >= 2 ? lang.Substring(0, 2) : "pl";
            var supportedLangDic = _cultureService.GetSupportedLanguages();

            var vm = supportedLangDic.TryGetValue(key, out var culture)
                ? culture
                : supportedLangDic.Values.First();

            TempData[TempDataKeys.CultureKey]           = vm.key;
            TempData[TempDataKeys.ReturnUrlFromCulture] = Request.Headers["Referer"].ToString();
            return(View(new LanguageVM(vm.key, vm.caption)));
        }