コード例 #1
0
        /// <summary>
        /// Creates user
        /// </summary>
        /// <param name="userDto">User to create</param>
        /// <returns>Returns operation details</returns>
        public async Task <OperationDetails> Create(UserDTO userDto)
        {
            var user = await DatabaseIdentity.UserManager.FindByEmailAsync(userDto.Email);

            if (user == null)
            {
                user = new ApplicationUser {
                    Email = userDto.Email, UserName = userDto.Email
                };
                var result = await DatabaseIdentity.UserManager.CreateAsync(user, userDto.Password);

                if (result.Errors.Count() > 0)
                {
                    return(new OperationDetails(false, result.Errors.FirstOrDefault(), ""));
                }

                await DatabaseIdentity.UserManager.AddToRoleAsync(user.Id, "user");

                User clientProfile = new User {
                    Id = user.Id, Name = userDto.Name
                };
                DatabaseIdentity.ClientManager.Create(clientProfile);
                await DatabaseIdentity.SaveAsync();

                return(new OperationDetails(true, "Success register", ""));
            }
            else
            {
                return(new OperationDetails(false, "User with this login is already exist", "Email"));
            }
        }
コード例 #2
0
 internal SqlDatabaseData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, SqlSku sku, string kind, string managedBy, DatabaseIdentity identity, CreateMode?createMode, string collation, long?maxSizeBytes, SampleSchemaName?sampleName, string elasticPoolId, string sourceDatabaseId, DatabaseStatus?status, Guid?databaseId, DateTimeOffset?creationOn, string currentServiceObjectiveName, string requestedServiceObjectiveName, string defaultSecondaryLocation, string failoverGroupId, DateTimeOffset?restorePointInOn, DateTimeOffset?sourceDatabaseDeletionOn, string recoveryServicesRecoveryPointId, string longTermRetentionBackupResourceId, string recoverableDatabaseId, string restorableDroppedDatabaseId, CatalogCollationType?catalogCollation, bool?zoneRedundant, DatabaseLicenseType?licenseType, long?maxLogSizeBytes, DateTimeOffset?earliestRestoreOn, DatabaseReadScale?readScale, int?highAvailabilityReplicaCount, SecondaryType?secondaryType, SqlSku currentSku, int?autoPauseDelay, BackupStorageRedundancy?currentBackupStorageRedundancy, BackupStorageRedundancy?requestedBackupStorageRedundancy, double?minCapacity, DateTimeOffset?pausedOn, DateTimeOffset?resumedOn, string maintenanceConfigurationId, bool?isLedgerOn, bool?isInfraEncryptionEnabled, Guid?federatedClientId, string sourceResourceId) : base(id, name, resourceType, systemData, tags, location)
 {
     Sku                               = sku;
     Kind                              = kind;
     ManagedBy                         = managedBy;
     Identity                          = identity;
     CreateMode                        = createMode;
     Collation                         = collation;
     MaxSizeBytes                      = maxSizeBytes;
     SampleName                        = sampleName;
     ElasticPoolId                     = elasticPoolId;
     SourceDatabaseId                  = sourceDatabaseId;
     Status                            = status;
     DatabaseId                        = databaseId;
     CreationOn                        = creationOn;
     CurrentServiceObjectiveName       = currentServiceObjectiveName;
     RequestedServiceObjectiveName     = requestedServiceObjectiveName;
     DefaultSecondaryLocation          = defaultSecondaryLocation;
     FailoverGroupId                   = failoverGroupId;
     RestorePointInOn                  = restorePointInOn;
     SourceDatabaseDeletionOn          = sourceDatabaseDeletionOn;
     RecoveryServicesRecoveryPointId   = recoveryServicesRecoveryPointId;
     LongTermRetentionBackupResourceId = longTermRetentionBackupResourceId;
     RecoverableDatabaseId             = recoverableDatabaseId;
     RestorableDroppedDatabaseId       = restorableDroppedDatabaseId;
     CatalogCollation                  = catalogCollation;
     ZoneRedundant                     = zoneRedundant;
     LicenseType                       = licenseType;
     MaxLogSizeBytes                   = maxLogSizeBytes;
     EarliestRestoreOn                 = earliestRestoreOn;
     ReadScale                         = readScale;
     HighAvailabilityReplicaCount      = highAvailabilityReplicaCount;
     SecondaryType                     = secondaryType;
     CurrentSku                        = currentSku;
     AutoPauseDelay                    = autoPauseDelay;
     CurrentBackupStorageRedundancy    = currentBackupStorageRedundancy;
     RequestedBackupStorageRedundancy  = requestedBackupStorageRedundancy;
     MinCapacity                       = minCapacity;
     PausedOn                          = pausedOn;
     ResumedOn                         = resumedOn;
     MaintenanceConfigurationId        = maintenanceConfigurationId;
     IsLedgerOn                        = isLedgerOn;
     IsInfraEncryptionEnabled          = isInfraEncryptionEnabled;
     FederatedClientId                 = federatedClientId;
     SourceResourceId                  = sourceResourceId;
 }
コード例 #3
0
 public void Dispose()
 {
     DatabaseIdentity.Dispose();
     DatabaseDomain.Dispose();
 }
コード例 #4
0
        internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element)
        {
            Optional <SqlSku>            sku                                     = default;
            Optional <string>            kind                                    = default;
            Optional <string>            managedBy                               = default;
            Optional <DatabaseIdentity>  identity                                = default;
            IDictionary <string, string> tags                                    = default;
            AzureLocation                      location                          = default;
            ResourceIdentifier                 id                                = default;
            string                             name                              = default;
            ResourceType                       type                              = default;
            SystemData                         systemData                        = default;
            Optional <CreateMode>              createMode                        = default;
            Optional <string>                  collation                         = default;
            Optional <long>                    maxSizeBytes                      = default;
            Optional <SampleSchemaName>        sampleName                        = default;
            Optional <string>                  elasticPoolId                     = default;
            Optional <string>                  sourceDatabaseId                  = default;
            Optional <DatabaseStatus>          status                            = default;
            Optional <Guid>                    databaseId                        = default;
            Optional <DateTimeOffset>          creationDate                      = default;
            Optional <string>                  currentServiceObjectiveName       = default;
            Optional <string>                  requestedServiceObjectiveName     = default;
            Optional <string>                  defaultSecondaryLocation          = default;
            Optional <string>                  failoverGroupId                   = default;
            Optional <DateTimeOffset>          restorePointInTime                = default;
            Optional <DateTimeOffset>          sourceDatabaseDeletionDate        = default;
            Optional <string>                  recoveryServicesRecoveryPointId   = default;
            Optional <string>                  longTermRetentionBackupResourceId = default;
            Optional <string>                  recoverableDatabaseId             = default;
            Optional <string>                  restorableDroppedDatabaseId       = default;
            Optional <CatalogCollationType>    catalogCollation                  = default;
            Optional <bool>                    zoneRedundant                     = default;
            Optional <DatabaseLicenseType>     licenseType                       = default;
            Optional <long>                    maxLogSizeBytes                   = default;
            Optional <DateTimeOffset>          earliestRestoreDate               = default;
            Optional <DatabaseReadScale>       readScale                         = default;
            Optional <int>                     highAvailabilityReplicaCount      = default;
            Optional <SecondaryType>           secondaryType                     = default;
            Optional <SqlSku>                  currentSku                        = default;
            Optional <int>                     autoPauseDelay                    = default;
            Optional <BackupStorageRedundancy> currentBackupStorageRedundancy    = default;
            Optional <BackupStorageRedundancy> requestedBackupStorageRedundancy  = default;
            Optional <double>                  minCapacity                       = default;
            Optional <DateTimeOffset>          pausedDate                        = default;
            Optional <DateTimeOffset>          resumedDate                       = default;
            Optional <string>                  maintenanceConfigurationId        = default;
            Optional <bool>                    isLedgerOn                        = default;
            Optional <bool>                    isInfraEncryptionEnabled          = default;
            Optional <Guid>                    federatedClientId                 = default;
            Optional <string>                  sourceResourceId                  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = SqlSku.DeserializeSqlSku(property.Value);
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("managedBy"))
                {
                    managedBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = DatabaseIdentity.DeserializeDatabaseIdentity(property.Value);
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("createMode"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            createMode = new CreateMode(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("collation"))
                        {
                            collation = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("maxSizeBytes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            maxSizeBytes = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("sampleName"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            sampleName = new SampleSchemaName(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("elasticPoolId"))
                        {
                            elasticPoolId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("sourceDatabaseId"))
                        {
                            sourceDatabaseId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("status"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            status = new DatabaseStatus(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("databaseId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            databaseId = property0.Value.GetGuid();
                            continue;
                        }
                        if (property0.NameEquals("creationDate"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            creationDate = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("currentServiceObjectiveName"))
                        {
                            currentServiceObjectiveName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("requestedServiceObjectiveName"))
                        {
                            requestedServiceObjectiveName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("defaultSecondaryLocation"))
                        {
                            defaultSecondaryLocation = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("failoverGroupId"))
                        {
                            failoverGroupId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("restorePointInTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            restorePointInTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("sourceDatabaseDeletionDate"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            sourceDatabaseDeletionDate = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("recoveryServicesRecoveryPointId"))
                        {
                            recoveryServicesRecoveryPointId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("longTermRetentionBackupResourceId"))
                        {
                            longTermRetentionBackupResourceId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("recoverableDatabaseId"))
                        {
                            recoverableDatabaseId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("restorableDroppedDatabaseId"))
                        {
                            restorableDroppedDatabaseId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("catalogCollation"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            catalogCollation = new CatalogCollationType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("zoneRedundant"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            zoneRedundant = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("licenseType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            licenseType = new DatabaseLicenseType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("maxLogSizeBytes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            maxLogSizeBytes = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("earliestRestoreDate"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            earliestRestoreDate = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("readScale"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            readScale = new DatabaseReadScale(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("highAvailabilityReplicaCount"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            highAvailabilityReplicaCount = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("secondaryType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            secondaryType = new SecondaryType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("currentSku"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            currentSku = SqlSku.DeserializeSqlSku(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("autoPauseDelay"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            autoPauseDelay = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("currentBackupStorageRedundancy"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            currentBackupStorageRedundancy = new BackupStorageRedundancy(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("requestedBackupStorageRedundancy"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            requestedBackupStorageRedundancy = new BackupStorageRedundancy(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("minCapacity"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            minCapacity = property0.Value.GetDouble();
                            continue;
                        }
                        if (property0.NameEquals("pausedDate"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            pausedDate = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("resumedDate"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            resumedDate = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("maintenanceConfigurationId"))
                        {
                            maintenanceConfigurationId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("isLedgerOn"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            isLedgerOn = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("isInfraEncryptionEnabled"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            isInfraEncryptionEnabled = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("federatedClientId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            federatedClientId = property0.Value.GetGuid();
                            continue;
                        }
                        if (property0.NameEquals("sourceResourceId"))
                        {
                            sourceResourceId = property0.Value.GetString();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new SqlDatabaseData(id, name, type, systemData, tags, location, sku.Value, kind.Value, managedBy.Value, identity.Value, Optional.ToNullable(createMode), collation.Value, Optional.ToNullable(maxSizeBytes), Optional.ToNullable(sampleName), elasticPoolId.Value, sourceDatabaseId.Value, Optional.ToNullable(status), Optional.ToNullable(databaseId), Optional.ToNullable(creationDate), currentServiceObjectiveName.Value, requestedServiceObjectiveName.Value, defaultSecondaryLocation.Value, failoverGroupId.Value, Optional.ToNullable(restorePointInTime), Optional.ToNullable(sourceDatabaseDeletionDate), recoveryServicesRecoveryPointId.Value, longTermRetentionBackupResourceId.Value, recoverableDatabaseId.Value, restorableDroppedDatabaseId.Value, Optional.ToNullable(catalogCollation), Optional.ToNullable(zoneRedundant), Optional.ToNullable(licenseType), Optional.ToNullable(maxLogSizeBytes), Optional.ToNullable(earliestRestoreDate), Optional.ToNullable(readScale), Optional.ToNullable(highAvailabilityReplicaCount), Optional.ToNullable(secondaryType), currentSku.Value, Optional.ToNullable(autoPauseDelay), Optional.ToNullable(currentBackupStorageRedundancy), Optional.ToNullable(requestedBackupStorageRedundancy), Optional.ToNullable(minCapacity), Optional.ToNullable(pausedDate), Optional.ToNullable(resumedDate), maintenanceConfigurationId.Value, Optional.ToNullable(isLedgerOn), Optional.ToNullable(isInfraEncryptionEnabled), Optional.ToNullable(federatedClientId), sourceResourceId.Value));
        }