public void AddLocalization(AdminLocalizationIndexViewModel model)
 {
     _localizationService
     .AddLocalization(new LocalizedStringFull()
     {
         Culture = model.SelectedCulture,
         Key     = model.Key,
         Value   = model.Value
     });
 }
コード例 #2
0
        public async Task SeedDataAsync()
        {
            await _localization.AddLocalization();

            if (await _roleManager.FindByNameAsync(Constants.Administrator) == null)
            {
                await _roleManager.CreateAsync(new IdentityRole(Constants.Administrator));
            }

            if (await _roleManager.FindByNameAsync(Constants.Moderator) == null)
            {
                await _roleManager.CreateAsync(new IdentityRole(Constants.Moderator));
            }

            if (await _roleManager.FindByNameAsync(Constants.Employee) == null)
            {
                await _roleManager.CreateAsync(new IdentityRole(Constants.Employee));
            }

            if (await _userManager.FindByNameAsync(Constants.Email) == null)
            {
                var result = await _userManager.CreateAsync(_users[3], Constants.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(_users[3], Constants.Administrator);
                }
            }

            if (await _userManager.FindByNameAsync("*****@*****.**") == null)
            {
                var result = await _userManager.CreateAsync(_users[0], Constants.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(_users[0], Constants.Employee);
                }
            }

            if (await _userManager.FindByNameAsync("*****@*****.**") == null)
            {
                var result = await _userManager.CreateAsync(_users[1], Constants.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(_users[1], Constants.Employee);
                }
            }

            if (await _userManager.FindByNameAsync("*****@*****.**") == null)
            {
                var result = await _userManager.CreateAsync(_users[2], Constants.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(_users[2], Constants.Employee);
                }
            }

            if (!_context.Categories.Any())
            {
                await _context.Categories.AddRangeAsync(_categories);
            }

            if (!_context.Tickets.Any())
            {
                await _context.Tickets.AddRangeAsync(_tickets);
            }

            if (!_context.Events.Any())
            {
                await _context.Events.AddRangeAsync(_events);
            }

            if (!_context.Cities.Any())
            {
                await _context.Cities.AddRangeAsync(_cities);
            }

            if (!_context.Venues.Any())
            {
                await _context.Venues.AddRangeAsync(_venues);
            }

            await _context.SaveChangesAsync();
        }