/// <summary>
 /// Converts from an API object to a PowerShell object
 /// </summary>
 /// <param name="resp">The object to transform</param>
 /// <returns>The converted location capability model</returns>
 private LocationCapabilityModel CreateLocationCapabilityModel(Management.Sql.Models.LocationCapability resp)
 {
     LocationCapabilityModel model = new LocationCapabilityModel();
     model.LocationName = resp.Name;
     model.Status = resp.Status;
     model.SupportedServerVersions = resp.SupportedServerVersions.Select(v => { return CreateSupportedVersionsModel(v); }).ToList();
     return model;
 }
 /// <summary>
 /// Filter the results based on the server version name
 /// </summary>
 /// <param name="model">The model to filter</param>
 private void FilterByServerVersion(LocationCapabilityModel model)
 {
     // Remove all server versions that don't match the desired name
     model.SupportedServerVersions =
         model.SupportedServerVersions
             .Where(obj => { return obj.ServerVersionName == this.ServerVersionName; })
             .ToList();
 }
        /// <summary>
        /// Filter the results based on the Edition Name
        /// </summary>
        /// <param name="model">The model to filter</param>
        private void FilterByEditionName(LocationCapabilityModel model)
        {
            foreach (var version in model.SupportedServerVersions)
            {
                // Remove all editions that do not match the desired edition name
                version.SupportedEditions =
                    version.SupportedEditions
                        .Where(e => { return e.EditionName == this.EditionName; })
                        .ToList();
            }

            // Remove server versions that have no supported editions after filtering
            model.SupportedServerVersions = model.SupportedServerVersions.Where(v => v.SupportedEditions.Count > 0).ToList();
        }
        /// <summary>
        /// Filter the results based on the Service Objective Name
        /// </summary>
        /// <param name="model">The model to filter</param>
        private void FilterByServiceObjectiveName(LocationCapabilityModel model)
        {
            foreach (var version in model.SupportedServerVersions)
            {
                foreach (var edition in version.SupportedEditions)
                {
                    // Remove all service objectives with a name that does not match the desired value
                    edition.SupportedServiceObjectives =
                        edition.SupportedServiceObjectives
                            .Where(slo => { return slo.ServiceObjectiveName == this.ServiceObjectiveName; })
                            .ToList();
                }

                // Remove editions that have no supported service objectives after filtering
                version.SupportedEditions = version.SupportedEditions.Where(e => e.SupportedServiceObjectives.Count > 0).ToList();
            }

            // Remove server versions that have no supported editions after filtering
            model.SupportedServerVersions = model.SupportedServerVersions.Where(v => v.SupportedEditions.Count > 0).ToList();
        }
        /// <summary>
        /// Filter the results based on what is marked as status
        /// </summary>
        /// <param name="model">The model to filter</param>
        private void FilterByDefaults(LocationCapabilityModel model)
        {
            model.SupportedServerVersions = model.SupportedServerVersions.Where(v => { return v.Status == "Default"; }).ToList();

            // Get all defaults
            var defaultVersion = model.SupportedServerVersions;
            defaultVersion[0].SupportedEditions = defaultVersion[0].SupportedEditions.Where(v => { return v.Status == "Default"; }).ToList();
            var defaultEdition = defaultVersion[0].SupportedEditions;
            defaultEdition[0].SupportedServiceObjectives = defaultEdition[0].SupportedServiceObjectives.Where(v => { return v.Status == "Default"; }).ToList();
            var defaultServiceObjective = defaultEdition[0].SupportedServiceObjectives;

            // Assign defaults back to model.
            defaultServiceObjective[0].SupportedMaxSizes = defaultServiceObjective[0].SupportedMaxSizes.Where(v => { return v.Status == "Default"; }).ToList();
            defaultEdition[0].SupportedServiceObjectives = defaultServiceObjective;
            defaultVersion[0].SupportedEditions = defaultEdition;
            model.SupportedServerVersions = defaultVersion;
        }
        /// <summary>
        /// Given a <see cref="LocationCapabilityModel"/> constructs a formatted string of its expanded details to the desired depth.
        /// </summary>
        /// <param name="model">The model details</param>
        /// <param name="depth">The depth to expand to</param>
        /// <returns>The formatted string containing the model details</returns>
        private string CreateExpandedDetails(LocationCapabilityModel model, int depth)
        {
            StringBuilder builder = new StringBuilder();

            foreach (var version in model.SupportedServerVersions)
            {
                string versionInfo = GetVersionInformation(version);

                if (depth > 1)
                {
                    ExpandEdition(depth, builder, version, versionInfo);
                }
                else
                {
                    builder.AppendLine(versionInfo);
                }
            }

            return builder.ToString();
        }