Exemple #1
0
        public static async Task InitialSetup(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            var context     = new DataWebserviceContext();
            var roleManager = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >();
            var userManager = serviceProvider.GetRequiredService <UserManager <IdentityUser> >();

            //Create Roles
            string[]       roleNames = { "Super Admin", "Installer", "Demo", "User" };
            IdentityResult roleResult;

            foreach (var name in roleNames)
            {
                var roleExist = await roleManager.RoleExistsAsync(name);

                if (!roleExist)
                {
                    roleResult = await roleManager.CreateAsync(new IdentityRole(name));
                }
            }

            //Create Admin
            var email    = "*****@*****.**";
            var password = "******";

            var admin = new IdentityUser
            {
                UserName = email,
                Email    = email
            };

            var user = await userManager.FindByEmailAsync(email);

            if (user == null)
            {
                var createAdmin = await userManager.CreateAsync(admin, password);

                if (createAdmin.Succeeded)
                {
                    foreach (var role in roleNames)
                    {
                        await userManager.AddToRoleAsync(admin, role);
                    }
                }
            }
        }
 public SensorLogsController(DataWebserviceContext context)
 {
     _context = context;
 }
Exemple #3
0
 public SensorTests(DataWebserviceContext context)
 {
     _context = context;
 }
Exemple #4
0
 public UserTests(DataWebserviceContext context)
 {
     _context = context;
 }
Exemple #5
0
 public UsersController(DataWebserviceContext context)
 {
     _context = context;
 }
Exemple #6
0
 public RoleController(DataWebserviceContext context, RoleManager <IdentityRole> roleManager, UserManager <IdentityUser> userManager)
 {
     _context     = context;
     _roleManager = roleManager;
     _userManager = userManager;
 }
Exemple #7
0
 public RoomAccessesController(DataWebserviceContext context)
 {
     _context = context;
 }
Exemple #8
0
 public RoomTests(DataWebserviceContext context)
 {
     _context = context;
 }
Exemple #9
0
 public DataOriginalController(DataWebserviceContext context)
 {
     _context = context;
 }