示例#1
0
        //added code to configureroles
        private async Task CreateUserRoles(IServiceProvider serviceProvider)
        {
            var RoleManager = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >();
            var UserManager = serviceProvider.GetRequiredService <UserManager <ApplicationUser> >();


            IdentityResult roleResult;
            //Adding Addmin Role
            ArrayList roleList = new ArrayList {
                "Super", "Admin", "Sales", "Operations", "FieldForce"
            };

            for (int i = 0; i < roleList.Count; i++)
            {
                var roleCheck = await RoleManager.RoleExistsAsync(roleList[i].ToString());

                if (!roleCheck)
                {
                    //create the roles and seed them to the database
                    roleResult = await RoleManager.CreateAsync(new IdentityRole(roleList[i].ToString()));
                }
            }

            //Assign Admin role to super User here we have given our newly loregistered login id for Admin management
            var             settings = GetAdminSettings.GetSettings();
            ApplicationUser user     = await UserManager.FindByEmailAsync(settings.AdminEmailId);

            if (user != null)
            {
                var User = new ApplicationUser();
                await UserManager.AddToRoleAsync(user, "Super");

                //Approve super admin
                user.isApproved = true;
                await UserManager.UpdateAsync(user);
            }
        }
        public Task SendEmailAsync(string email, string subject, string message)
        {
            var settings = GetAdminSettings.GetSettings();

            return(Execute(settings.SendGridKey, subject, message, email));
        }
 public IActionResult Settings()
 {
     return(View(GetAdminSettings.GetSettings()));
 }