public PartialViewResult AddRole2PermissionReturnPartialView(int permissionId, int roleId)
 {
     ApplicationRoleManager.AddPermission2Role(roleId, permissionId);
     return(PartialView("_ListRolesTable4Permission", ApplicationRoleManager.GetPermission(permissionId)));
 }
 public PartialViewResult AddPermission2RoleReturnPartialView(int id, int permissionId)
 {
     ApplicationRoleManager.AddPermission2Role(id, permissionId);
     return(PartialView("_ListPermissions", ApplicationRoleManager.GetRole(id)));
 }
Esempio n. 3
0
        protected override void Seed(RBACDbContext context)
        {
            //Create Default Roles...
            IList <ApplicationRole> defaultRoles = new List <ApplicationRole>();

            defaultRoles.Add(new ApplicationRole {
                Name = c_SysAdmin, RoleDescription = "Allows system administration of Users/Roles/Permissions", LastModified = DateTime.Now, IsSysAdmin = true
            });
            defaultRoles.Add(new ApplicationRole {
                Name = c_DefaultUser, RoleDescription = "Default role with limited permissions", LastModified = DateTime.Now, IsSysAdmin = false
            });

            ApplicationRoleManager RoleManager = new ApplicationRoleManager(new ApplicationRoleStore(context));

            foreach (ApplicationRole role in defaultRoles)
            {
                RoleManager.Create(role);
            }

            //Create User...
            var user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "System", Lastname = "Administrator", LastModified = DateTime.Now, Inactive = false, EmailConfirmed = true
            };

            ApplicationUserManager UserManager = new ApplicationUserManager(new ApplicationUserStore(context));
            var result = UserManager.Create(user, "Pa55w0rd");

            if (result.Succeeded)
            {
                //Add User to Admin Role...
                UserManager.AddToRole(user.Id, c_SysAdmin);
            }


            //Create Default User...
            user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "Default", Lastname = "User", LastModified = DateTime.Now, Inactive = false, EmailConfirmed = true
            };
            result = UserManager.Create(user, "S4l3su53r");

            if (result.Succeeded)
            {
                //Add User to Admin Role...
                UserManager.AddToRole(user.Id, c_DefaultUser);
            }

            //Create User with NO Roles...
            user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "Guest", Lastname = "User", LastModified = DateTime.Now, Inactive = false, EmailConfirmed = true
            };
            result = UserManager.Create(user, "Gu3st12");


            base.Seed(context);

            //Create a permission...
            PERMISSION _permission = new PERMISSION();

            _permission.PermissionDescription = "Home-Reports";
            ApplicationRoleManager.AddPermission(_permission);

            //Add Permission to DefaultUser Role...
            ApplicationRoleManager.AddPermission2Role(context.Roles.Where(p => p.Name == c_DefaultUser).First().Id, context.PERMISSIONS.First().PermissionId);
        }
Esempio n. 4
0
        protected override void Seed(RBACDbContext context)
        {
            //Application parameters
            using (RBACDbContext db = new RBACDbContext())
            {
                db.PARAMETERS.AddOrUpdate(s => s.Name,
                                          new PARAMETER {
                    Name = "UserLockoutEnabled", Value = "true", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "AccountLockoutTimeSpan", Value = "15", MemberID = 1, TypeID = ParameterType.SmallInteger, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "MaxFailedAccessAttemptsBeforeLockout", Value = "5", MemberID = 1, TypeID = ParameterType.SmallInteger, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "2FADeviceType", Value = "Email Code", MemberID = 1, TypeID = ParameterType.ShortString, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "2FAEnabled", Value = "false", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "AccountVerificationRequired", Value = "false", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "PasswordRequiredLength", Value = "6", MemberID = 1, TypeID = ParameterType.SmallInteger, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "PasswordRequireNonLetterOrDigit", Value = "true", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "PasswordRequireDigit", Value = "true", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "PasswordRequireLowercase", Value = "true", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "PasswordRequireUppercase", Value = "true", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "SmtpEMailFrom", Value = "*****@*****.**", MemberID = 1, TypeID = ParameterType.ShortString, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "SmtpServer", Value = "smtp.live.com", MemberID = 1, TypeID = ParameterType.ShortString, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "SmtpPort", Value = "587", MemberID = 1, TypeID = ParameterType.SmallInteger, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "SmtpUsername", Value = "*****@*****.**", MemberID = 1, TypeID = ParameterType.ShortString, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "SmtpPassword", Value = "password", MemberID = 1, TypeID = ParameterType.ShortString, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "SmtpNetworkDeliveryMethodEnabled", Value = "true", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "SMSSid", Value = "*****@*****.**", MemberID = 1, TypeID = ParameterType.ShortString, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "SMSToken", Value = "smtp.live.com", MemberID = 1, TypeID = ParameterType.ShortString, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "SMSFromPhone", Value = "587", MemberID = 1, TypeID = ParameterType.ShortString, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "general-audit-enabled", Value = "true", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "general-app-maintenance-enabled", Value = "false", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "general-app-maintenance-url", Value = "Offline", MemberID = 1, TypeID = ParameterType.Bool, Created = DateTime.Now
                },
                                          new PARAMETER {
                    Name = "general-app-maintenance-allowedIPs", Value = "", MemberID = 1, TypeID = ParameterType.ShortString, Created = DateTime.Now
                }
                                          );
                db.SaveChanges();
            }


            //Create Default Roles...
            IList <ApplicationRole> defaultRoles = new List <ApplicationRole>();

            defaultRoles.Add(new ApplicationRole {
                Name = c_SysAdmin, RoleDescription = "Autorise la gestion des utilisateurs/rôles/permissions", LastModified = DateTime.Now, IsSysAdmin = true
            });
            defaultRoles.Add(new ApplicationRole {
                Name = c_DefaultUser, RoleDescription = "Role par defaut avec restrictions", LastModified = DateTime.Now, IsSysAdmin = false
            });

            ApplicationRoleManager RoleManager = new ApplicationRoleManager(new ApplicationRoleStore(context));

            foreach (ApplicationRole role in defaultRoles)
            {
                RoleManager.Create(role);
            }

            //Create User...
            var user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "Système", Lastname = "Administrateur", LastModified = DateTime.Now, Inactive = false, EmailConfirmed = true
            };

            ApplicationUserManager UserManager = new ApplicationUserManager(new ApplicationUserStore(context));
            var result = UserManager.Create(user, "Password64!");

            if (result.Succeeded)
            {
                //Add User to Admin Role...
                UserManager.AddToRole(user.Id, c_SysAdmin);
            }


            //Create Default User...
            user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "Standard", Lastname = "Utilisateur", LastModified = DateTime.Now, Inactive = false, EmailConfirmed = true
            };
            result = UserManager.Create(user, "Password64!");

            if (result.Succeeded)
            {
                //Add User to Admin Role...
                UserManager.AddToRole(user.Id, c_DefaultUser);
            }

            //Create User with NO Roles...
            user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "Invité", Lastname = "Utilisateur", LastModified = DateTime.Now, Inactive = false, EmailConfirmed = true
            };
            result = UserManager.Create(user, "Password64!");


            base.Seed(context);

            //Create a permission...
            PERMISSION _permission = new PERMISSION();

            _permission.PermissionDescription = "Main-Reports";
            ApplicationRoleManager.AddPermission(_permission);

            //Add Permission to DefaultUser Role...
            ApplicationRoleManager.AddPermission2Role(context.Roles.Where(p => p.Name == c_DefaultUser).First().Id, context.PERMISSIONS.First().PermissionId);
        }
Esempio n. 5
0
        protected override void Seed(GovHistoryDbContext context)
        {
            //Create Default Roles...
            IList <ApplicationRole> defaultRoles = new List <ApplicationRole>();

            defaultRoles.Add(new ApplicationRole {
                Name = c_SysAdmin, RoleDescription = "Amministratore di sistema di Utenti/Ruoli/Permessi", LastModified = DateTime.Now, IsSysAdmin = true
            });
            defaultRoles.Add(new ApplicationRole {
                Name = c_DefaultUser, RoleDescription = "Ruolo di default con permessi limitati", LastModified = DateTime.Now, IsSysAdmin = false
            });

            ApplicationRoleManager RoleManager = new ApplicationRoleManager(new ApplicationRoleStore(context));

            foreach (ApplicationRole role in defaultRoles)
            {
                RoleManager.Create(role);
            }

            //Create User...
            var user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "System", Lastname = "Administrator", LastModified = DateTime.Now, Inactive = false, EmailConfirmed = true
            };

            ApplicationUserManager UserManager = new ApplicationUserManager(new ApplicationUserStore(context));
            var result = UserManager.Create(user, "Roberta4@");

            if (result.Succeeded)
            {
                //Add User to Admin Role...
                UserManager.AddToRole(user.Id, c_SysAdmin);
            }


            //Create Default User...
            user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "Default", Lastname = "User", LastModified = DateTime.Now, Inactive = false, EmailConfirmed = true
            };
            result = UserManager.Create(user, "Roberta4@");

            if (result.Succeeded)
            {
                //Add User to Admin Role...
                UserManager.AddToRole(user.Id, c_DefaultUser);
            }

            //Create User with NO Roles...
            user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "Guest", Lastname = "User", LastModified = DateTime.Now, Inactive = false, EmailConfirmed = true
            };
            result = UserManager.Create(user, "Roberta4@");
            if (result.Succeeded)
            {
                //Add User to Admin Role...
                UserManager.AddToRole(user.Id, c_DefaultUser);
            }

            base.Seed(context);

            //Create a permission...
            PERMISSION _permission = new PERMISSION();

            _permission.PermissionDescription = "Home-Reports";
            ApplicationRoleManager.AddPermission(_permission);

            //Add Permission to DefaultUser Role...
            ApplicationRoleManager.AddPermission2Role(context.Roles.Where(p => p.Name == c_DefaultUser).First().Id, context.PERMISSIONS.First().PermissionId);
        }
Esempio n. 6
0
        protected override void Seed(AlgrmsWebContext context)
        {
            //Create Default Roles...
            IList <ApplicationRole> defaultRoles = new List <ApplicationRole>();

            defaultRoles.Add(new ApplicationRole {
                Name = c_SysAdmin, RoleDescription = "Allows system administration of Users/Roles/Permissions", LastModified = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null), IsSysAdmin = true
            });
            defaultRoles.Add(new ApplicationRole {
                Name = c_DefaultUser, RoleDescription = "Default role with limited permissions", LastModified = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null), IsSysAdmin = false
            });

            ApplicationRoleManager RoleManager = new ApplicationRoleManager(new ApplicationRoleStore(context));

            foreach (ApplicationRole role in defaultRoles)
            {
                RoleManager.Create(role);
            }

            //Create User...
            var user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "System", Lastname = "Administrator", LastModified = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null), Inactive = false, EmailConfirmed = true
            };

            ApplicationUserManager UserManager = new ApplicationUserManager(new ApplicationUserStore(context));
            var result = UserManager.Create(user, "Pa55w0rd");

            if (result.Succeeded)
            {
                //Add User to Admin Role...
                UserManager.AddToRole(user.Id, c_SysAdmin);
            }


            //Create Default User...
            user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "Default", Lastname = "User", LastModified = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null), Inactive = false, EmailConfirmed = true
            };
            result = UserManager.Create(user, "S4l3su53r");

            if (result.Succeeded)
            {
                //Add User to Admin Role...
                UserManager.AddToRole(user.Id, c_DefaultUser);
            }

            //Create User with NO Roles...
            user = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", Firstname = "Guest", Lastname = "User", LastModified = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null), Inactive = false, EmailConfirmed = true
            };
            result = UserManager.Create(user, "Gu3st12");
            base.Seed(context);


            context.Countries.AddOrUpdate(
                c => c.country_id, new Country
            {
                country_id   = 156,
                iso_code_3   = "NG",
                country_name = "Nigeria",
                created_at   = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null),
                phone_code   = 234,
                updated_at   = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null),
            });
            context.Zones.AddOrUpdate(
                z => z.zone_id,
                new Zone {
                country_id = 156, state_name = "Lagos", code = "LG"
            },
                new Zone {
                country_id = 156, state_name = "Ogun", code = "OG"
            },
                new Zone {
                country_id = 156, state_name = "Abuja", code = "FCT"
            },
                new Zone {
                country_id = 156, state_name = "ABIA", code = "AB"
            }
                );
            context.TaxCategories.AddOrUpdate(
                t => t.category_code, new TaxCategory {
                category_code = "1000", title = "Permit", description = "Revenue category for license or permit", created_at = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null), updated_at = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null)
            },
                new TaxCategory {
                category_code = "2000", title = "Rate", description = "Revenue category for rate", created_at = DateTime.ParseExact(DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null).ToString(), "yyyy-MM-dd", null), updated_at = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null)
            },
                new TaxCategory {
                category_code = "3000", title = "Levy", description = "Revenue category for license or permit", created_at = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null), updated_at = DateTime.ParseExact(DateTime.Now.ToString(), "yyyy-MM-dd", null)
            }
                );
            context.SaveChanges();
            //base.Seed(context);

            //Create a permission...
            PERMISSION _permission = new PERMISSION();

            _permission.PermissionDescription = "Home-Reports";
            ApplicationRoleManager.AddPermission(_permission);

            //Add Permission to DefaultUser Role...
            ApplicationRoleManager.AddPermission2Role(context.Roles.Where(p => p.Name == c_DefaultUser).First().Id, context.PERMISSIONS.First().PermissionId);
        }