Created
March 28, 2018 15:35
-
-
Save Alexei000/97459c0b3010fe391ff0ba7584e3d8c7 to your computer and use it in GitHub Desktop.
Get all environments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// gets a list of environment service models | |
/// </summary> | |
/// <param name="applySecurity">specifies if current user security rules should be applied</param> | |
/// <param name="enabledOnly">specifies if only enabled environments will be returned</param> | |
/// <returns>a list of environment service models</returns> | |
public List<EnvironmentServiceModel> GetAllEnvironments(bool applySecurity, bool enabledOnly) | |
{ | |
var serviceModels = EnvironmentProxyService.Environments.Where(env => !enabledOnly || env.IsEnabled); | |
if (!applySecurity) | |
return serviceModels.ToList(); | |
var allowedEnvironments = SecurityService.GetUserAllowedEnvironments(userId: null, enabledOnly: enabledOnly); | |
serviceModels = serviceModels.Where(env => allowedEnvironments.Contains(env.EnvironmentId)); | |
return serviceModels.ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment