/// <summary>
        /// Create the model from user input
        /// </summary>
        /// <param name="model">Model retrieved from service</param>
        /// <returns>The model that was passed in</returns>
        protected override IEnumerable <AzureSqlElasticPoolModel> ApplyUserInputToModel(IEnumerable <AzureSqlElasticPoolModel> model)
        {
            string location = ModelAdapter.GetServerLocation(ResourceGroupName, ServerName);
            List <AzureSqlElasticPoolModel> newEntity = new List <AzureSqlElasticPoolModel>();
            AzureSqlElasticPoolModel        newModel  = new AzureSqlElasticPoolModel()
            {
                ResourceGroupName = ResourceGroupName,
                ServerName        = ServerName,
                ElasticPoolName   = ElasticPoolName,
                Tags          = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
                Location      = location,
                ZoneRedundant = MyInvocation.BoundParameters.ContainsKey("ZoneRedundant") ? (bool?)ZoneRedundant.ToBool() : null,
                MaxSizeBytes  = MyInvocation.BoundParameters.ContainsKey("StorageMB") ? (long?)(StorageMB * Megabytes) : null,
                LicenseType   = LicenseType,
                MaintenanceConfigurationId = MaintenanceConfigurationId,
            };


            if (ParameterSetName == DtuPoolParameterSet)
            {
                string edition = string.IsNullOrWhiteSpace(Edition) ? null : Edition;

                if (!string.IsNullOrWhiteSpace(edition))
                {
                    newModel.SkuName  = AzureSqlElasticPoolAdapter.GetPoolSkuName(edition);
                    newModel.Edition  = edition;
                    newModel.Capacity = MyInvocation.BoundParameters.ContainsKey("Dtu") ? (int?)Dtu : null;
                }

                newModel.DatabaseCapacityMin = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMin") ? (double?)DatabaseDtuMin : null;
                newModel.DatabaseCapacityMax = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMax") ? (double?)DatabaseDtuMax : null;
            }
            else
            {
                newModel.SkuName  = AzureSqlElasticPoolAdapter.GetPoolSkuName(Edition);
                newModel.Edition  = Edition;
                newModel.Capacity = VCore;
                newModel.Family   = ComputeGeneration;

                newModel.DatabaseCapacityMin          = MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMin") ? (double?)DatabaseVCoreMin : null;
                newModel.DatabaseCapacityMax          = MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMax") ? (double?)DatabaseVCoreMax : null;
                newModel.HighAvailabilityReplicaCount = MyInvocation.BoundParameters.ContainsKey("HighAvailabilityReplicaCount") ? (int?)HighAvailabilityReplicaCount : null;
            }

            newEntity.Add(newModel);
            return(newEntity);
        }
 public void GetPoolSkuName()
 {
     Assert.Equal(
         "BasicPool",
         AzureSqlElasticPoolAdapter.GetPoolSkuName("Basic"));
     Assert.Equal(
         "StandardPool",
         AzureSqlElasticPoolAdapter.GetPoolSkuName("Standard"));
     Assert.Equal(
         "PremiumPool",
         AzureSqlElasticPoolAdapter.GetPoolSkuName("Premium"));
     Assert.Equal(
         "GP",
         AzureSqlElasticPoolAdapter.GetPoolSkuName("GeneralPurpose"));
     Assert.Equal(
         "BC",
         AzureSqlElasticPoolAdapter.GetPoolSkuName("BusinessCritical"));
 }
        /// <summary>
        /// Create the model from user input
        /// </summary>
        /// <param name="model">Model retrieved from service</param>
        /// <returns>The model that was passed in</returns>
        protected override IEnumerable <AzureSqlElasticPoolModel> ApplyUserInputToModel(IEnumerable <AzureSqlElasticPoolModel> model)
        {
            string location = ModelAdapter.GetServerLocation(ResourceGroupName, ServerName);
            List <AzureSqlElasticPoolModel> newEntity = new List <AzureSqlElasticPoolModel>();
            AzureSqlElasticPoolModel        newModel  = new AzureSqlElasticPoolModel()
            {
                ResourceGroupName = ResourceGroupName,
                ServerName        = ServerName,
                ElasticPoolName   = ElasticPoolName,
                Tags          = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
                Location      = location,
                ZoneRedundant = MyInvocation.BoundParameters.ContainsKey("ZoneRedundant") ? (bool?)ZoneRedundant.ToBool() : null,
                MaxSizeBytes  = MyInvocation.BoundParameters.ContainsKey("StorageMB") ? (long?)(StorageMB * Megabytes) : null,
                LicenseType   = LicenseType ?? model.FirstOrDefault().LicenseType
            };

            var elasticPool = ModelAdapter.GetElasticPool(ResourceGroupName, ServerName, ElasticPoolName);

            Management.Sql.Models.Sku poolCurrentSku = new Management.Sql.Models.Sku()
            {
                Name     = elasticPool.SkuName,
                Tier     = elasticPool.Edition,
                Family   = elasticPool.Family,
                Capacity = elasticPool.Capacity
            };
            Management.Sql.Models.ElasticPoolPerDatabaseSettings poolCurrentDbSetting = new Management.Sql.Models.ElasticPoolPerDatabaseSettings()
            {
                MinCapacity = elasticPool.DatabaseCapacityMin,
                MaxCapacity = elasticPool.DatabaseCapacityMax
            };

            if (ParameterSetName == DtuPoolParameterSet)
            {
                if (!string.IsNullOrWhiteSpace(Edition) || MyInvocation.BoundParameters.ContainsKey("Dtu"))
                {
                    string edition = string.IsNullOrWhiteSpace(Edition) ? poolCurrentSku.Tier : Edition;

                    newModel.SkuName  = AzureSqlElasticPoolAdapter.GetPoolSkuName(edition);
                    newModel.Edition  = edition;
                    newModel.Capacity = MyInvocation.BoundParameters.ContainsKey("Dtu") ? (int?)Dtu : null;
                }

                if (MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMin") || MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMax"))
                {
                    newModel.DatabaseCapacityMin = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMin") ? (double?)DatabaseDtuMin : null;
                    newModel.DatabaseCapacityMax = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMax") ? (double?)DatabaseDtuMax : null;
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(Edition) || MyInvocation.BoundParameters.ContainsKey("VCore") || !string.IsNullOrWhiteSpace(ComputeGeneration))
                {
                    string skuTier = string.IsNullOrWhiteSpace(Edition) ? poolCurrentSku.Tier : Edition;

                    newModel.SkuName  = AzureSqlElasticPoolAdapter.GetPoolSkuName(skuTier);
                    newModel.Edition  = skuTier;
                    newModel.Capacity = MyInvocation.BoundParameters.ContainsKey("VCore") ? VCore : poolCurrentSku.Capacity;
                    newModel.Family   = string.IsNullOrWhiteSpace(ComputeGeneration) ? poolCurrentSku.Family : ComputeGeneration;
                }

                if (MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMin") || MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMax"))
                {
                    newModel.DatabaseCapacityMin = MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMin") ? (double?)DatabaseVCoreMin : null;
                    newModel.DatabaseCapacityMax = MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMax") ? (double?)DatabaseVCoreMax : null;
                }
            }

            newEntity.Add(newModel);
            return(newEntity);
        }