private static IEnumerable <string> GetLine(string[] headers, DashboardConfiguration dashboardConfiguration) { yield return(dashboardConfiguration.Id); yield return(dashboardConfiguration.Name); yield return(dashboardConfiguration.Team); foreach (var environment in headers.Skip(MandatoryHeaders.Length)) { var env = dashboardConfiguration.Environments.FirstOrDefault(x => x.Name == environment); yield return(env?.Enabled == EnvironmentState.Enabled ? "x" : ""); } }
public void Save(DashboardConfiguration dashboardConfiguration) { var stuff = GetStuff(); var dashboardConfigurations = stuff.Configurations.ToList(); var i = dashboardConfigurations.FindIndex(x => x.Id == dashboardConfiguration.Id); var newDashboardConfig = i == -1; if (!newDashboardConfig) { dashboardConfigurations[i] = dashboardConfiguration; } else { dashboardConfigurations.Add(dashboardConfiguration); } var markdownTable = CreateMarkdownTable( environments: MandatoryHeaders.Concat(stuff.Environments).ToArray(), dashboardConfigurations: dashboardConfigurations); _fileSystem.GetFile(DashboardConfigurationFileName).WriteLines(markdownTable); }