private async Task updateAlternatives(ModelCompound compound, Alternative[] snapshotAlternatives, string alternativeGroupName) { if (snapshotAlternatives == null) { return; } var alternativeGroup = compound.ParameterAlternativeGroup(alternativeGroupName); //Remove all alternatives except calculated ones alternativeGroup.AllAlternatives.ToList().Where(x => !x.IsCalculated).Each(alternativeGroup.RemoveAlternative); //Reset the default flag that will be read from snapshot alternativeGroup.AllAlternatives.Each(x => x.IsDefault = false); var alternatives = await _alternativeMapper.MapToModels(snapshotAlternatives, alternativeGroup); alternatives?.Each(alternativeGroup.AddAlternative); //Ensure that we have at least one default alternative (might not be the case if only calcualted alternatives were saved) var defaultAlternative = alternativeGroup.DefaultAlternative; if (defaultAlternative != null) { defaultAlternative.IsDefault = true; } }
private async Task updateAlternatives(ModelCompound compound, Alternative[] snapshotAlternatives, string alternativeGroupName) { if (snapshotAlternatives == null) { return; } var alternativeGroup = compound.ParameterAlternativeGroup(alternativeGroupName); //Remove all alternatives except calculated ones alternativeGroup.AllAlternatives.ToList().Where(x => !x.IsCalculated).Each(alternativeGroup.RemoveAlternative); var alternatives = await _alternativeMapper.MapToModels(snapshotAlternatives, alternativeGroup); alternatives?.Each(alternativeGroup.AddAlternative); }