Ejemplo n.º 1
0
        public async Task <GetLanguageForEditOutput> GetLanguageForEdit(NullableIdDto input)
        {
            ApplicationLanguage language = null;

            if (input.Id.HasValue)
            {
                language = await _languageRepository.GetAsync(input.Id.Value);
            }

            var output = new GetLanguageForEditOutput();

            //Language
            output.Language = language != null
                ? ObjectMapper.Map <ApplicationLanguageEditDto>(language)
                : new ApplicationLanguageEditDto();

            //Language names
            output.LanguageNames = CultureHelper
                                   .AllCultures
                                   .Select(c => new ComboboxItemDto(c.Key, c.Value + " (" + c.Key + ")")
            {
                IsSelected = output.Language.Name == c.Key
            })
                                   .ToList();

            //Flags
            output.Flags = FamFamFamFlagsHelper
                           .FlagClassNames
                           .OrderBy(f => f)
                           .Select(f => new ComboboxItemDto(f, FamFamFamFlagsHelper.GetCountryCode(f))
            {
                IsSelected = output.Language.Icon == f
            })
                           .ToList();

            return(output);
        }