public DbKeeper(SecurityDB _db, DbSearcher _asker) { db = _db; db.Configuration.ProxyCreationEnabled = false; asker = _asker; }
public SecurityManager(atriumBE.atriumManager atmng) : base(atmng.AppMan) { base.DAL = atmng.DALMngr; myatMng = atmng; MyDS = new SecurityDB(); MyDS.EnforceConstraints = false; }
public DbSearcher(SecurityDB dataBase) { db = dataBase; //db.Configuration.ProxyCreationEnabled = false; }
public static void AddTheEssentialDataIfDeleteFromDB(this SecurityDB db) { var asker = new DbSearcher(db); var keeper = new DbKeeper(db, asker); string superadmin = AppSettings.SuperAdmin; string appName = AppSettings.ApplicationName; string userManagerRoleName = AppSettings.UserManagerRoleName; string rolerManagerRoleName = AppSettings.RoleManagerRoleName; int appId = AppSettings.ApplicationId; if (asker.FindApplicationById(appId) == null) { keeper.AddApplication(appName, superadmin, appId); } Role userManager = asker.FindRole(userManagerRoleName, appId); if (userManager == null) { userManager = keeper.AddRole(new Role() { Name = userManagerRoleName }, superadmin, appId); } string[] userOperations = { "AddUser", "DeleteUser", "AssignRoleToUser", "UnAssignRoleFromUser", "SeeUserDetails", "SeeAllUsers", }; foreach (var p in userOperations) { var tmp = asker.FindOperation(p, appId); if (tmp == null) { tmp = keeper.AddOperation(p, superadmin, appId); } keeper.AddOperationToRole(tmp.Id, userManager.Id, "", superadmin, appId); } Role roleManager = asker.FindRole(rolerManagerRoleName, appId); if (roleManager == null) { roleManager = keeper.AddRole(new Role() { Name = rolerManagerRoleName }, superadmin, appId); } string[] roleOperations = { "AddRole", "DeleteRole", "AssignUserToRole", "UnAssignUserFromRole", "SeeRoleDetails", "SeeAllRoles", "UnAssignOperationFromRole", "AssignOperationToRole" }; foreach (var p in roleOperations) { var tmp = asker.FindOperation(p, appId); if (tmp == null) { tmp = keeper.AddOperation(p, superadmin, appId); } keeper.AddOperationToRole(tmp.Id, roleManager.Id, "", superadmin, appId); } User superAdmin = asker.FindUser(superadmin); if (superAdmin == null) { superAdmin = keeper.AddUserIfNotExisted(superadmin, "", "", superadmin); } keeper.AddUserToRole(superAdmin.Id, userManager.Id, superadmin); keeper.AddUserToRole(superAdmin.Id, roleManager.Id, superadmin); db.SaveChanges(); }
protected BaseController() { var db = new SecurityDB(); ask = new DbSearcher(db); }