Represents an Azure Sql Database
        /// <summary>
        /// Creates or updates an Azure Sql Database.
        /// </summary>
        /// <param name="resourceGroup">The name of the resource group</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="model">The input parameters for the create/update operation</param>
        /// <returns>The upserted Azure Sql Database</returns>
        internal AzureSqlDatabaseModel UpsertDatabase(string resourceGroup, string serverName, AzureSqlDatabaseModel model)
        {
            var resp = Communicator.CreateOrUpdate(resourceGroup, serverName, model.DatabaseName, Util.GenerateTracingId(), new DatabaseCreateOrUpdateParameters()
            {
                Location = model.Location,
                Properties = new DatabaseCreateOrUpdateProperties()
                {
                    Collation = model.CollationName,
                    Edition = model.Edition == DatabaseEdition.None ? null : model.Edition.ToString(),
                    MaxSizeBytes = model.MaxSizeBytes,
                    RequestedServiceObjectiveId = model.RequestedServiceObjectiveId,
                    ElasticPoolName = model.ElasticPoolName,
                    RequestedServiceObjectiveName = model.RequestedServiceObjectiveName,
                }
            });

            return CreateDatabaseModelFromResponse(resourceGroup, serverName, resp);
        }
        /// <summary>
        /// Converts the response from the service to a powershell database object
        /// </summary>
        /// <param name="resourceGroupName">The resource group the server is in</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="database">The service response</param>
        /// <returns>The converted model</returns>
        public static AzureSqlDatabaseModel CreateDatabaseModelFromResponse(string resourceGroup, string serverName, Management.Sql.Models.Database database)
        {
            AzureSqlDatabaseModel model = new AzureSqlDatabaseModel();
            Guid id = Guid.Empty;
            DatabaseEdition edition = DatabaseEdition.None;

            model.ResourceGroupName = resourceGroup;
            model.ServerName = serverName;
            model.CollationName = database.Properties.Collation;
            model.CreationDate = database.Properties.CreationDate;
            model.CurrentServiceObjectiveName = database.Properties.ServiceObjective;
            model.MaxSizeBytes = database.Properties.MaxSizeBytes;
            model.DatabaseName = database.Name;
            model.Status = database.Properties.Status;
            model.Tags = database.Tags as Dictionary<string, string>;
            model.ElasticPoolName = database.Properties.ElasticPoolName;
            model.Location = database.Location;

            Guid.TryParse(database.Properties.CurrentServiceObjectiveId, out id);
            model.CurrentServiceObjectiveId = id;

            Guid.TryParse(database.Properties.DatabaseId, out id);
            model.DatabaseId = id;

            Enum.TryParse<DatabaseEdition>(database.Properties.Edition, true, out edition);
            model.Edition = edition;

            Guid.TryParse(database.Properties.RequestedServiceObjectiveId, out id);
            model.RequestedServiceObjectiveId = id;

            return model;
        }
 /// <summary>
 /// Restore a given Sql Azure Database
 /// </summary>
 /// <param name="resourceGroup">The name of the resource group</param>
 /// <param name="restorePointInTime">A point to time to restore to (for PITR and dropped DB restore)</param>
 /// <param name="resourceId">The resource ID of the DB to restore (live, geo backup, or deleted database)</param>
 /// <param name="model">An object modeling the database to create via restore</param>
 /// <param name="parameters">Parameters describing the database restore request</param>
 /// <returns>Restored database object</returns>
 internal AzureSqlDatabaseModel RestoreDatabase(string resourceGroup, DateTime restorePointInTime, string resourceId, AzureSqlDatabaseModel model)
 {
     DatabaseCreateOrUpdateParameters parameters = new DatabaseCreateOrUpdateParameters()
         {
             Location = model.Location,
             Properties = new DatabaseCreateOrUpdateProperties()
             {
                 Edition = model.Edition == DatabaseEdition.None ? null : model.Edition.ToString(),
                 RequestedServiceObjectiveId = model.RequestedServiceObjectiveId,
                 ElasticPoolName = model.ElasticPoolName,
                 RequestedServiceObjectiveName = model.RequestedServiceObjectiveName,
                 SourceDatabaseId = resourceId,
                 RestorePointInTime = restorePointInTime,
                 CreateMode = model.CreateMode
             }
         };
     var resp = Communicator.RestoreDatabase(resourceGroup, model.ServerName, model.DatabaseName, Util.GenerateTracingId(), parameters);
     return AzureSqlDatabaseAdapter.CreateDatabaseModelFromResponse(resourceGroup, model.ServerName, resp);
 }