Example #1
0
        public async Task <IActionResult> Settings()
        {
            var englishTask = _translationsRepo.GetTranslations(Languages.English);
            var germanTask  = _translationsRepo.GetTranslations(Languages.German);

            await Task.WhenAll(englishTask, germanTask);

            HttpContext.Request.Cookies.TryGetValue("english", out var english);
            HttpContext.Request.Cookies.TryGetValue("german", out var german);
            HttpContext.Request.Cookies.TryGetValue("timezone", out var timezone);

            var model = new SettingsViewModel
            {
                EnglishTranslations = new TranslationViewModel
                {
                    Language            = Languages.English,
                    Translations        = englishTask.Result,
                    SelectedTranslation = english,
                },
                GermanTranslations = new TranslationViewModel
                {
                    Language            = Languages.German,
                    Translations        = germanTask.Result,
                    SelectedTranslation = german
                },
                TimeZones = TimeZoneInfo.GetSystemTimeZones()
                            .Select(timeZone => new TimeZoneViewModel(timeZone)),
                SelectedTimeZone = timezone
            };

            return(View(model));
        }
Example #2
0
        public async Task <IActionResult> Get(Languages language)
        {
            try
            {
                var translations = await _repository.GetTranslations(language);

                return(Ok(translations));
            }
            catch (ArgumentException)
            {
                return(NotFound());
            }
        }