Beispiel #1
0
        public DeploymentConfig RemoveApplication(AppIdentity appIdentity)
        {
            string appId   = appIdentity.Id;
            string version = appIdentity.Version.ToString();
            var    apps    = GetAppsCopy();

            if (!apps.ContainsKey(appId))
            {
                throw new InvalidOperationException($"Cannot remove version {version} because {appId} was not found");
            }
            AppDeploymentConfig appDeploymentConfig = apps[appId];

            if (!appDeploymentConfig.Versions.ContainsKey(version))
            {
                throw new InvalidOperationException(
                          $"Cannot remove version {version} from application {appId} because version {version} was not found");
            }
            appDeploymentConfig = appDeploymentConfig.RemoveVersionConfig(version);
            if (!appDeploymentConfig.Versions.Any())
            {
                apps.Remove(appId);
            }
            else
            {
                apps[appId] = appDeploymentConfig;
            }

            return(new DeploymentConfig(apps));
        }