protected override IEnumerable EvaluateVector(ContextType context) { int?roleId = FindRole(this.RoleName, context); if (roleId == null) { return(null); } return(DB.Servers_SearchServers(Has_ServerRole_Id: roleId, In_Environment_Id: null) #if Otter .Servers_Extended #elif BuildMaster .Servers #endif .Select(s => s.Server_Name)); }
private int?FindRole(string roleName, ContextType context) { var allRoles = DB.ServerRoles_GetServerRoles(); if (!string.IsNullOrEmpty(roleName)) { return(allRoles .FirstOrDefault(r => r.ServerRole_Name.Equals(roleName, StringComparison.OrdinalIgnoreCase)) ?.ServerRole_Id); } else { return(allRoles .FirstOrDefault(r => r.ServerRole_Id == context.ServerRoleId) ?.ServerRole_Id); } }
private int?FindEnvironment(string environmentName, ContextType context) { var allEnvironments = DB.Environments_GetEnvironments(); if (!string.IsNullOrEmpty(environmentName)) { return(allEnvironments .FirstOrDefault(e => e.Environment_Name.Equals(environmentName, StringComparison.OrdinalIgnoreCase)) ?.Environment_Id); } else { return(allEnvironments .FirstOrDefault(e => e.Environment_Id == context.EnvironmentId) ?.Environment_Id); } }