Exemple #1
0
        public async Task SeedAsync(SpravkiDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Users.Any())
            {
                return;
            }

            var userManager = serviceProvider.GetRequiredService <UserManager <ApplicationUser> >();

            string email    = "*****@*****.**";
            string roleName = "Administrator";
            string password = "******";

            var user = new ApplicationUser
            {
                UserName = email,
                Email    = email,
            };

            await userManager.CreateAsync(user, password);

            await userManager.AddToRoleAsync(user, roleName);

            await dbContext.SaveChangesAsync();
        }
Exemple #2
0
        public async Task SeedAsync(SpravkiDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            var logger = serviceProvider.GetService <ILoggerFactory>().CreateLogger(typeof(ApplicationDbContextSeeder));

            var seeders = new List <ISeeder>
            {
                new RolesSeeder(),
                new AdministratorSeeder(),
            };

            foreach (var seeder in seeders)
            {
                await seeder.SeedAsync(dbContext, serviceProvider);

                await dbContext.SaveChangesAsync();

                logger.LogInformation($"Seeder {seeder.GetType().Name} done.");
            }
        }
 public ProductsService(SpravkiDbContext db)
 {
     this.db = db;
 }
        public async Task SeedAsync(SpravkiDbContext dbContext, IServiceProvider serviceProvider)
        {
            var roleManager = serviceProvider.GetRequiredService <RoleManager <ApplicationRole> >();

            await SeedRoleAsync(roleManager, AdministratorRoleName);
        }
 public SalesService(SpravkiDbContext db)
 {
     this.db = db;
 }
 public PharmaciesService(SpravkiDbContext db)
 {
     this.db = db;
 }
Exemple #7
0
 public DistributorService(SpravkiDbContext db)
 {
     this.db = db;
 }
Exemple #8
0
 public CompaniesService(SpravkiDbContext db)
 {
     this.db = db;
 }
 public RegionsService(SpravkiDbContext db)
 {
     this.db = db;
 }
Exemple #10
0
        public DistributorsController(SpravkiDbContext context)

        {
            this.context = context;
        }