Ejemplo n.º 1
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();

            CustomUserRole adminEmployeeRole = ObjectSpace.FindObject <CustomUserRole>(
                new BinaryOperator("Name", "Admin"));

            if (adminEmployeeRole == null)
            {
                adminEmployeeRole                  = ObjectSpace.CreateObject <CustomUserRole>();
                adminEmployeeRole.Name             = "Admin";
                adminEmployeeRole.IsAdministrative = true;
                adminEmployeeRole.Save();
            }
            CustomUser adminEmployee = ObjectSpace.FindObject <CustomUser>(
                new BinaryOperator("UserName", "Admin"));

            if (adminEmployee == null)
            {
                adminEmployee          = ObjectSpace.CreateObject <CustomUser>();
                adminEmployee.UserName = "******";
                adminEmployee.SetPassword("");
                adminEmployee.Roles.Add(adminEmployeeRole);
            }

            ObjectSpace.CommitChanges(); //Uncomment this line to persist created object(s).
        }