public async Task Should_Add_Language_To_Host()
        {
            await _languageManager.AddAsync(new ApplicationLanguage(null, "fr", "French"));

            var languages = await _languageManager.GetLanguagesAsync(null);

            languages.Count.ShouldBe(4);
            languages.FirstOrDefault(l => l.Name == "fr").ShouldNotBeNull();
        }
示例#2
0
        // [AbpAuthorize(PermissionNames.AdminPage_Language)]
        protected virtual async Task CreateLanguageAsync(ApplicationLanguageEditDto input)
        {
            if (AbpSession.MultiTenancySide != MultiTenancySides.Host)
            {
                throw new UserFriendlyException(L("TenantsCannotCreateLanguage"));
            }
            var culture = CultureHelper.GetCultureInfoByChecking(input.Name);

            await CheckLanguageIfAlreadyExists(culture.Name);

            input.Icon = FamFamFamFlagsHelper
                         .FlagClassNames
                         .Where(p => FamFamFamFlagsHelper.GetCountryCode(p) == input.Name)
                         .Select(p => p)
                         .FirstOrDefault();

            await applicationLanguageManager.AddAsync(
                new ApplicationLanguage(
                    AbpSession.TenantId,
                    culture.Name,
                    culture.DisplayName,
                    input.Icon,
                    !input.IsEnabled
                    )


                );
        }
        /// <summary>
        /// Adds a new available language to the app
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task AddLanguage(LanguageInput input)
        {
            var newLanguage = new ApplicationLanguage(AbpSession.TenantId, input.LangCode, input.DisplayName, input.Icon);
            await _applicationLanguageManager.AddAsync(newLanguage);

            await _languagesAppNotificationSender.SendLanguageCreatedNotification(newLanguage, (await GetCurrentUserAsync()));
        }
示例#4
0
        public async Task <LanguageDto> Create(CreateLanguageDto input)
        {
            var language = ObjectMapper.Map <ApplicationLanguage>(input);
            await _appLanguageManager.AddAsync(language);

            return(ObjectMapper.Map <LanguageDto>(language));
        }
示例#5
0
 protected virtual async Task CreateLanguageAsync(CreateOrUpdateLanguageInput input)
 {
     var culture = GetCultureInfoByChecking(input.Language.Name);
     await _applicationLanguageManager.AddAsync(
         new ApplicationLanguage(
             AbpSession.TenantId,
             culture.Name,
             culture.DisplayName,
             input.Language.Icon
             )
         );
 }
示例#6
0
        protected virtual async Task CreateLanguageAsync(CreateOrUpdateLanguageInput input)
        {
            var culture = CultureHelper.GetCultureInfoByChecking(input.Language.Name);

            await CheckLanguageIfAlreadyExists(culture.Name);

            await _applicationLanguageManager.AddAsync(
                new ApplicationLanguage(
                    AbpSession.TenantId,
                    culture.Name,
                    culture.DisplayName,
                    input.Language.Icon
                    )
            {
                IsDisabled = !input.Language.IsEnabled
            }
                );
        }
        protected virtual async Task CreateLanguageAsync(CreateOrUpdateLanguageInput input)
        {
            var culture = CultureHelper.GetCultureInfo(input.Language.Name);

            if (await LanguageExists(culture.Name))
            {
                throw new UserFriendlyException(L("ThisLanguageAlreadyExists"));
            }

            var newLanguage = new ApplicationLanguage
            {
                TenantId    = AbpSession.TenantId,
                Name        = culture.Name,
                DisplayName = culture.DisplayName,
                Icon        = input.Language.Icon,
                IsDisabled  = !input.Language.IsEnabled
            };

            await _languageManager.AddAsync(newLanguage);
        }
示例#8
0
        protected virtual async Task CreateLanguageAsync(CreateOrUpdateLanguageInput input)
        {
            if (AbpSession.MultiTenancySide != MultiTenancySides.Host)
            {
                throw new UserFriendlyException(L("TenantsCannotCreateLanguage"));
            }

            var culture = CultureHelper.GetCultureInfoByChecking(input.Language.Name);

            await CheckLanguageIfAlreadyExists(culture.Name);

            await _applicationLanguageManager.AddAsync(
                new ApplicationLanguage(
                    AbpSession.TenantId,
                    culture.Name,
                    culture.DisplayName,
                    input.Language.Icon
                    )
            {
                IsDisabled = !input.Language.IsEnabled
            }
                );
        }
示例#9
0
 public async Task AddAsync(ApplicationLanguage language)
 {
     await _languageManager.AddAsync(language);
 }