Compare commits

..

No commits in common. "master" and "Fullepi_Sandbox" have entirely different histories.

527 changed files with 6463 additions and 32317 deletions

View File

@ -1,6 +0,0 @@
aycode.core rebuild product mode
copy: \AyCode.Core\AyCode.Services.Server\bin\Product\net8.0 to \AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0
Setting.cs baseurl átállítani: devrelease test.touriam.com, release:touriam.com
program.cs-ben átírni a kívánt portot 7116-ról
megnézni a Loglevelt és ha olyan, átállítani TiamConstClient.DefaultLogLevelClient
database connection, server side loglevel string átírni tiamwebappserver\appsettings.json

File diff suppressed because it is too large Load Diff

View File

@ -1,958 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<SchemaComparison>
<Version>10</Version>
<SourceModelProvider>
<ConnectionBasedModelProvider>
<ConnectionString>Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Persist Security Info=True;User ID=Anata_Development_Team;Pooling=False;Multiple Active Result Sets=False;Connect Timeout=60;Encrypt=True;Trust Server Certificate=True;Command Timeout=0</ConnectionString>
</ConnectionBasedModelProvider>
</SourceModelProvider>
<TargetModelProvider>
<ConnectionBasedModelProvider>
<ConnectionString>Data Source=185.51.190.197;Initial Catalog=TIAM_DEVRELEASE;Persist Security Info=True;User ID=Anata_Development_Team;Pooling=False;Multiple Active Result Sets=False;Connect Timeout=60;Encrypt=True;Trust Server Certificate=True;Command Timeout=0</ConnectionString>
</ConnectionBasedModelProvider>
</TargetModelProvider>
<SchemaCompareSettingsService>
<SchemaCompareSettingsService>
<PropertyElementName>
<Name>Version</Name>
<Value>1</Value>
</PropertyElementName>
</SchemaCompareSettingsService>
<ConfigurationOptionsElement>
<PropertyElementName>
<Name>PlanGenerationType</Name>
<Value>SqlDeploymentOptions</Value>
</PropertyElementName>
<PropertyElementName>
<Name>AllowExistingModelErrors</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>AllowIncompatiblePlatform</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>AllowTableRecreation</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>BackupDatabaseBeforeChanges</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreIndexesStatisticsOnEnclaveEnabledColumns</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>BlockOnPossibleDataLoss</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>BlockWhenDriftDetected</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>CompareUsingTargetCollation</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>CommentOutSetVarDeclarations</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>CreateNewDatabase</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DeployDatabaseInSingleUserMode</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DisableAndReenableDdlTriggers</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DisableIndexesForDataPhase</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DisableParallelismForEnablingIndexes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotAlterChangeDataCaptureObjects</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotAlterReplicatedObjects</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DropConstraintsNotInSource</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DropDmlTriggersNotInSource</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DropExtendedPropertiesNotInSource</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DropIndexesNotInSource</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DropPermissionsNotInSource</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DropObjectsNotInSource</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DropRoleMembersNotInSource</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DropStatisticsNotInSource</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>GenerateSmartDefaults</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>HashObjectNamesInLogs</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreDdlTriggerOrder</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreDdlTriggerState</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreObjectPlacementOnPartitionScheme</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreAuthorizer</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreDefaultSchema</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreRouteLifetime</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreCryptographicProviderFilePath</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreComments</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreWhitespace</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreKeywordCasing</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreSemicolonBetweenStatements</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnorePartitionSchemes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreTablePartitionOptions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreWithNocheckOnCheckConstraints</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreWithNocheckOnForeignKeys</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreIdentitySeed</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreIncrement</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreFillFactor</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreIndexPadding</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreColumnCollation</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreColumnOrder</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreLockHintsOnIndexes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreTableOptions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreIndexOptions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreDmlTriggerOrder</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreDmlTriggerState</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreAnsiNulls</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreQuotedIdentifiers</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreUserSettingsObjects</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreFilegroupPlacement</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreFullTextCatalogFilePath</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreFileAndLogFilePath</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreLoginSids</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreNotForReplication</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreFileSize</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreSensitivityClassifications</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>AllowUnsafeRowLevelSecurityDataMovement</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IncludeCompositeObjects</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IncludeTransactionalScripts</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IsAlwaysEncryptedParameterizationEnabled</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>NoAlterStatementsToChangeCLRTypes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>PopulateFilesOnFileGroups</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>PreserveIdentityLastValues</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>RegisterDataTierApplication</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>PerformIndexOperationsOnline</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>RebuildIndexesOfflineForDataPhase</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>RestoreSequenceCurrentValue</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ScriptDatabaseCollation</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ScriptDatabaseCompatibility</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ScriptDatabaseOptions</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ScriptDeployStateChecks</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ScriptFileSize</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ScriptNewConstraintValidation</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ScriptRefreshModule</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>TargetDatabaseName</Name>
<Value>TIAM_DEVRELEASE</Value>
</PropertyElementName>
<PropertyElementName>
<Name>TargetConnectionString</Name>
<Value>Data Source=185.51.190.197;Initial Catalog=TIAM_DEVRELEASE;Persist Security Info=True;User ID=Anata_Development_Team;Pooling=False;Multiple Active Result Sets=False;Connect Timeout=60;Encrypt=True;Trust Server Certificate=True;Application Name="Microsoft SQL Server Data Tools, Schema Compare";Command Timeout=0</Value>
</PropertyElementName>
<PropertyElementName>
<Name>TreatVerificationErrorsAsWarnings</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>UnmodifiableObjectWarnings</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>VerifyCollationCompatibility</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>VerifyDeployment</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>RunDeploymentPlanExecutors</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>AllowDropBlockingAssemblies</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotEvaluateSqlCmdVariables</Name>
<Value>True</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropAggregates</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropApplicationRoles</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropAssemblies</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropAsymmetricKeys</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropAudits</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropBrokerPriorities</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropCertificates</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropClrUserDefinedTypes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropColumnEncryptionKeys</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropColumnMasterKeys</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropContracts</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropCredentials</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropDatabaseScopedCredentials</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropCryptographicProviders</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropDatabaseAuditSpecifications</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropDatabaseRoles</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropDatabaseTriggers</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreDatabaseWorkloadGroups</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropDatabaseWorkloadGroups</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>IgnoreWorkloadClassifiers</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropWorkloadClassifiers</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropDefaults</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropEndpoints</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropErrorMessages</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropEventNotifications</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropEventSessions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropExtendedProperties</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropExternalDataSources</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropExternalFileFormats</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropExternalLanguages</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropExternalLibraries</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropExternalStreamingJobs</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropExternalTables</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropExternalStreams</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropFilegroups</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropFiles</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropFileTables</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropFullTextCatalogs</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropFullTextStoplists</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropTableValuedFunctions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropLinkedServerLogins</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropLinkedServers</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropLogins</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropMessageTypes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropPartitionFunctions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropPartitionSchemes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropPermissions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropQueues</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropRemoteServiceBindings</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropRoleMembership</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropRoutes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropRules</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropScalarValuedFunctions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropSearchPropertyLists</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropSecurityPolicies</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropSequences</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropServerAuditSpecifications</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropServerRoleMembership</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropServerRoles</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropServerTriggers</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropServices</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropSignatures</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropStoredProcedures</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropSymmetricKeys</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropSynonyms</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropTables</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropUserDefinedDataTypes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropUserDefinedTableTypes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropUsers</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropViews</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>DoNotDropXmlSchemaCollections</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeAggregates</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeApplicationRoles</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeAssemblies</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeAsymmetricKeys</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeAudits</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeBrokerPriorities</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeCertificates</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeClrUserDefinedTypes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeColumnEncryptionKeys</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeColumnMasterKeys</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeContracts</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeCredentials</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeDatabaseScopedCredentials</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeCryptographicProviders</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeDatabaseAuditSpecifications</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeDatabaseRoles</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeDatabaseTriggers</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeDefaults</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeEndpoints</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeErrorMessages</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeEventNotifications</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeExternalDataSources</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeExternalFileFormats</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeExternalLanguages</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeExternalLibraries</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeExternalStreamingJobs</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeExternalTables</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeExternalStreams</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeEventSessions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeFilegroups</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeFiles</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeFileTables</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeFullTextCatalogs</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeFullTextStoplists</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeTableValuedFunctions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeLinkedServerLogins</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeLinkedServers</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeLogins</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeMessageTypes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludePartitionFunctions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludePartitionSchemes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeQueues</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeRemoteServiceBindings</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeRoutes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeRules</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeScalarValuedFunctions</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeSearchPropertyLists</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeSecurityPolicies</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeSequences</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeServerAuditSpecifications</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeServerRoleMembership</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeServerRoles</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeServerTriggers</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeServices</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeSignatures</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeStoredProcedures</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeSymmetricKeys</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeSynonyms</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeTables</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeUserDefinedDataTypes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeUserDefinedTableTypes</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeUsers</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeViews</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>ExcludeXmlSchemaCollections</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>AllowExternalLibraryPaths</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>AllowExternalLanguagePaths</Name>
<Value>False</Value>
</PropertyElementName>
<PropertyElementName>
<Name>Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlAssemblyFile</Name>
<Value>ExcludedType</Value>
</PropertyElementName>
</ConfigurationOptionsElement>
</SchemaCompareSettingsService>
<SchemaCompareViewSettings>
<GroupBy>2</GroupBy>
<ZoomLevel>100</ZoomLevel>
<Filter>Equals_Objects,Not_Supported_Deploy</Filter>
</SchemaCompareViewSettings>
<ExcludedSourceElements>
<SelectedItem Type="Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlUser, Microsoft.Data.Tools.Schema.Sql, Version=162.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>Anata_Development_Team</Name>
</SelectedItem>
<SelectedItem Type="Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlFile, Microsoft.Data.Tools.Schema.Sql, Version=162.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>TIAM_DEV_log</Name>
</SelectedItem>
<SelectedItem Type="Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlFile, Microsoft.Data.Tools.Schema.Sql, Version=162.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>TIAM_DEV</Name>
</SelectedItem>
<SelectedItem Type="Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlFile, Microsoft.Data.Tools.Schema.Sql, Version=162.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>TIAM_DEVRELEASE</Name>
</SelectedItem>
<SelectedItem Type="Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlFile, Microsoft.Data.Tools.Schema.Sql, Version=162.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>TIAM_DEVRELEASE_log</Name>
</SelectedItem>
</ExcludedSourceElements>
</SchemaComparison>

View File

@ -1,87 +0,0 @@
using AyCode.Core.Consts;
using AyCode.Core.Loggers;
namespace TIAM.Core.Consts;
public static class TiamConstClient
{
public static string DefaultLocale = "en-US";
public static Guid TransferProductId = Guid.Parse("814b5495-c2e9-4f1d-a73f-37cd5d353078");
public static Guid[] DevAdminIds = new Guid[2] { Guid.Parse("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd"), Guid.Parse("4cbaed43-2465-4d99-84f1-c8bc6b7025f7") };
public static Guid[] SysAdmins = new Guid[3]
{
Guid.Parse("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd"),
Guid.Parse("4cbaed43-2465-4d99-84f1-c8bc6b7025f7"),
Guid.Parse("540271f6-c604-4c16-8160-d5a7cafedf00")
};
public static Dictionary<string, Guid> SysAccounts = new Dictionary<string, Guid>
{
{ "SystemEmailSender", Guid.Parse("5e13e051-4fd6-4a30-a371-75cc785cfb84")},
};
public static string WelcomeEmailTemplateName = "WelcomeEmailTemplate";
public static string NewTransferEmailTemplateName = "NewTransferEmailTemplate";
public static string TransferModifiedEmailTemplateName = "TramsferModifiedEmailTemplate";
public static string ForgotPasswordEmailTemplateName = "ForgotPasswordEmailTemplate";
public static string GeneralEmailTemplateName = "GeneralEmailTemplate";
public static List<string> WelcomeEmailParameters = new List<string>()
{
"UserName",
"SettingBaseUrl",
"UserId",
"Token"
};
public static List<string> ForgotPasswordEmailParameters = new List<string>()
{
//string userName, string settingBaseUrl, string userId, string token
"UserName",
"SettingBaseUrl",
"UserId",
"Token"
};
public static List<string> NewTransferEmailParameters = new List<string>()
{
//string userName, string fromAddress, string toAddress, string appointment,
//string fullname,string passengerCount, string luggageCount, string settingBaseUrl, string transferId
"UserName",
"FromAddress",
"ToAddress",
"Appointment",
"FullName",
"PassengerCount",
"LuggageCount",
"SettingBaseUrl",
"TransferId"
};
public static List<string> GeneralEmailParameters = new List<string>()
{
//string userName, string settingBaseUrl, string userId, string token
"UserName",
"MessageBody",
"SettingBaseUrl",
"UserId"
};
#if RELEASE
public static string SystemEmailAddress = "test@touriam.com";
public static LogLevel DefaultLogLevelClient = LogLevel.Debug;
#else
public static string SystemEmailAddress = "test@touriam.com";
public static LogLevel DefaultLogLevelClient = LogLevel.Detail;
#endif
}
public class TiamConst : AcConst
{
public static string ProjectIdString = "684f34d1-163a-4077-918f-a9d9df5ce789";
static TiamConst()
{
ProjectId = Guid.Parse(ProjectIdString);
ProjectSalt = GenerateProjectSalt(ProjectId.ToString("N"));
}
}

View File

@ -5,5 +5,4 @@ public enum ProductType : byte
NotDefined = 0, NotDefined = 0,
Transfer = 5, Transfer = 5,
Hotel = 10, Hotel = 10,
Guide = 15,
} }

View File

@ -1,8 +0,0 @@
namespace TIAM.Core.Enums;
public enum SeatNumberPriceType : byte
{
Price1SeatNum = 0,
Price2SeatNum = 4,
Price3SeatNum = 8,
}

View File

@ -1,10 +1,7 @@
using System.ComponentModel.DataAnnotations; namespace TIAM.Core.Enums;
namespace TIAM.Core.Enums;
public enum TransferStatusType : byte public enum TransferStatusType : byte
{ {
[Display(Name = "OrderSubmittedDisplayName")]
OrderSubmitted = 5, OrderSubmitted = 5,
OrderConfirmed = 10, OrderConfirmed = 10,
AssignedToDriver = 15, AssignedToDriver = 15,

View File

@ -1,17 +0,0 @@
using AyCode.Core.Enums;
using AyCode.Core.Loggers;
namespace TIAM.Core.Loggers;
public class ConsoleLogWriter : AcConsoleLogWriter
{
public ConsoleLogWriter() : this(null)
{ }
public ConsoleLogWriter(string? categoryName = null) : base(categoryName)
{ }
public ConsoleLogWriter(AppType appType, LogLevel logLevel, string? callerClassName = null) : base(appType, logLevel, callerClassName)
{
}
}

View File

@ -1,12 +0,0 @@
using AyCode.Core.Loggers;
namespace TIAM.Core.Loggers;
public interface ILogger<TCategory> : ILogger
{
}
public interface ILogger : IAcLoggerBase
{
}

View File

@ -1,32 +0,0 @@
using AyCode.Core.Enums;
using AyCode.Core.Loggers;
namespace TIAM.Core.Loggers;
public class Logger<TCategory> : Logger, ILogger<TCategory>
{
public Logger() : base(typeof(TCategory).Name)
{ }
public Logger(params IAcLogWriterBase[] logWriters) : base(typeof(TCategory).Name, logWriters)
{ }
public Logger(AppType appType, LogLevel logLevel, params IAcLogWriterBase[] logWriters) : base(appType, logLevel, typeof(TCategory).Name, logWriters)
{ }
}
public class Logger : AcLoggerBase, ILogger
{
public Logger() : this(null)
{
}
public Logger(string? categoryName) : base(categoryName)
{ }
public Logger(string? categoryName, params IAcLogWriterBase[] logWriters) : base(categoryName, logWriters)
{ }
public Logger(AppType appType, LogLevel logLevel, string? categoryName, params IAcLogWriterBase[] logWriters) : base(appType, logLevel, categoryName, logWriters)
{ }
}

View File

@ -0,0 +1,23 @@
using AyCode.Core.Interfaces;
using Newtonsoft.Json;
using TIAM.Core.Interfaces;
namespace TIAM.Core;
public static class SerializeObjectToJsonExtensions
{
private static string SerializeObjectToJson<T>(T source)
{
JsonSerializerSettings options = new()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
NullValueHandling = NullValueHandling.Ignore
};
return JsonConvert.SerializeObject(source, options);
}
public static string ToJson<T>(this T source) where T : class, IAcSerializableToJson => SerializeObjectToJson(source);
public static string ToJson<T>(this IQueryable<T> source) where T : class, IAcSerializableToJson => SerializeObjectToJson(source);
public static string ToJson<T>(this IEnumerable<T> source) where T : class, IAcSerializableToJson => SerializeObjectToJson(source);
}

View File

@ -11,7 +11,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>

View File

@ -1,20 +1,17 @@
using AyCode.Database.Tests; using AyCode.Database.Tests;
using AyCode.Utils.Extensions; using AyCode.Utils.Extensions;
using Newtonsoft.Json; using Newtonsoft.Json;
using TIAM.Core;
using TIAM.Core.Enums; using TIAM.Core.Enums;
using TIAM.Database.DataLayers.Admins; using TIAM.Database.DataLayers.Admins;
using TIAM.Database.DbContexts.Admins; using TIAM.Database.DbContexts.Admins;
using TIAM.Database.DbSets.Emails;
using TIAM.Entities.Drivers; using TIAM.Entities.Drivers;
using TIAM.Entities.Emails; using TIAM.Entities.Emails;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
using AyCode.Core.Extensions;
using Microsoft.Extensions.DependencyInjection;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Addresses;
//using DevExpress.Pdf.Native.BouncyCastle.Asn1.Ocsp;
namespace TIAM.Database.Test namespace TIAM.Database.Test
{ {
@ -34,9 +31,9 @@ namespace TIAM.Database.Test
[DataRow("42968456-6EF3-4D9C-8BC4-0569A129AC05")] [DataRow("42968456-6EF3-4D9C-8BC4-0569A129AC05")]
public void GetPermissionViewBySubjectId_ReturnsPermissionContextMapping_WhenPermissionContextMappingExists(string subjectIdString) public void GetPermissionViewBySubjectId_ReturnsPermissionContextMapping_WhenPermissionContextMappingExists(string subjectIdString)
{ {
var subjectId = Guid.Parse(subjectIdString); var subjectId= Guid.Parse(subjectIdString);
var permMapping = Dal.GetPermissionContextsViewBySubjectId(subjectId).ToList(); var permMapping = Dal.GetPermissionContextsViewBySubjectId(subjectId).ToList();
Assert.IsNotNull(permMapping, "PermissionContextsView is null"); Assert.IsNotNull(permMapping, "PermissionContextsView is null");
Assert.IsTrue(permMapping.Count != 0, "PermissionContextsView count: 0"); Assert.IsTrue(permMapping.Count != 0, "PermissionContextsView count: 0");
} }
@ -47,7 +44,7 @@ namespace TIAM.Database.Test
{ {
var contextId = Guid.Parse(contextIdString); var contextId = Guid.Parse(contextIdString);
var permMapping = Dal.GetPermissionContextsViewByContextId(contextId).ToList(); var permMapping = Dal.GetPermissionContextsViewByContextId(contextId).ToList();
Assert.IsNotNull(permMapping, "PermissionContextsView is null"); Assert.IsNotNull(permMapping, "PermissionContextsView is null");
Assert.IsTrue(permMapping.Count != 0, "PermissionContextsView count: 0"); Assert.IsTrue(permMapping.Count != 0, "PermissionContextsView count: 0");
} }
@ -58,7 +55,7 @@ namespace TIAM.Database.Test
{ {
var contextId = Guid.Parse(contextIdString); var contextId = Guid.Parse(contextIdString);
var permMapping = await Dal.GetPermissionContextsViewByContextIdAsync(contextId); var permMapping = await Dal.GetPermissionContextsViewByContextIdAsync(contextId);
Assert.IsNotNull(permMapping, "PermissionContextsView is null"); Assert.IsNotNull(permMapping, "PermissionContextsView is null");
Assert.IsTrue(permMapping.Count != 0, "PermissionContextsView count: 0"); Assert.IsTrue(permMapping.Count != 0, "PermissionContextsView count: 0");
} }
@ -67,7 +64,7 @@ namespace TIAM.Database.Test
{ {
var productId = Guid.Parse(productIdString); var productId = Guid.Parse(productIdString);
var product = Dal.GetProductById(productId, true); var product = Dal.GetProductById(productId, true);
Assert.IsNotNull(product, "Product is null"); Assert.IsNotNull(product, "Product is null");
Assert.IsNotNull(product.Profile, "Profile is null"); Assert.IsNotNull(product.Profile, "Profile is null");
Assert.IsNotNull(product.Profile.Address, "Profile.Address is null"); Assert.IsNotNull(product.Profile.Address, "Profile.Address is null");
@ -78,7 +75,7 @@ namespace TIAM.Database.Test
[DataTestMethod] [DataTestMethod]
public void GetProducts_ReturnProductsJson_WhenProductsExist() public void GetProducts_ReturnProductsJson_WhenProductsExist()
{ {
var products = JsonConvert.DeserializeObject<List<Product>>(Dal.GetProductsJson(false)); var products = JsonConvert.DeserializeObject<List<Product>>(Dal.GetProductsJson(false));
Assert.IsNotNull(products, "Products is null"); Assert.IsNotNull(products, "Products is null");
Assert.IsTrue(products.Count > 0, "No products found"); Assert.IsTrue(products.Count > 0, "No products found");
@ -130,10 +127,6 @@ namespace TIAM.Database.Test
Assert.IsTrue(user.UserProductMappings.Count != 0, "UserProductMappings count: 0"); Assert.IsTrue(user.UserProductMappings.Count != 0, "UserProductMappings count: 0");
Assert.IsNotNull(user.UserProductMappings[0].Product, "Product is null"); Assert.IsNotNull(user.UserProductMappings[0].Product, "Product is null");
//ActivatorUtilities.CreateInstance<UserModelDto>(ServiceProvider, user);
var userModelDto = (UserModelDto)Activator.CreateInstance(typeof(UserModelDto), user);
Assert.IsNotNull(userModelDto);
} }
#region UserProductMapping #region UserProductMapping
@ -152,7 +145,7 @@ namespace TIAM.Database.Test
Assert.IsNotNull(userProductMapping.User.Profile.Address, "User.Profile.Address is null"); Assert.IsNotNull(userProductMapping.User.Profile.Address, "User.Profile.Address is null");
Assert.IsNotNull(userProductMapping.Product.Profile.Address, "Product.Profile.Address is null"); Assert.IsNotNull(userProductMapping.Product.Profile.Address, "Product.Profile.Address is null");
//Assert.IsTrue(userProductMapping.Transfers?.Count != 0, "Transfers?.Count == 0"); Assert.IsTrue(userProductMapping.Transfers?.Count != 0, "Transfers?.Count == 0");
Assert.IsTrue(userProductMapping.Id == userProductMappingId, "userProductMapping.Id != userProductMappingId"); Assert.IsTrue(userProductMapping.Id == userProductMappingId, "userProductMapping.Id != userProductMappingId");
} }
@ -162,8 +155,8 @@ namespace TIAM.Database.Test
{ {
var userProductCarId = Guid.Parse(userProductCarIdString); var userProductCarId = Guid.Parse(userProductCarIdString);
var serializedUserProductMapping = Dal.Session(ctx var serializedUserProductMapping = Dal.Session(ctx
=> ctx.UserProductMappings.FirstOrDefault(x => ctx.UserProductMappings.FirstOrDefault(x
=> x.JsonDetailModel != null && x.JsonDetailModel.Cars != null && x.JsonDetailModel.Cars.Any(c => c.UserProductCarId == userProductCarId))?.ToJson()); => x.JsonDetailModel != null && x.JsonDetailModel.Cars != null && x.JsonDetailModel.Cars.Any(c => c.UserProductCarId == userProductCarId))?.ToJson());
//var transfers = Dal.Session(x => x.GetTransfers()).ToList(); //var transfers = Dal.Session(x => x.GetTransfers()).ToList();
@ -181,7 +174,7 @@ namespace TIAM.Database.Test
Assert.IsNotNull(userProductMapping.JsonDetailModel, "User is null"); Assert.IsNotNull(userProductMapping.JsonDetailModel, "User is null");
Assert.IsNotNull(userProductMapping.JsonDetailModel.Cars, "Product is null"); Assert.IsNotNull(userProductMapping.JsonDetailModel.Cars, "Product is null");
//Assert.IsTrue(userProductMapping.Transfers?.Count != 0); Assert.IsTrue(userProductMapping.Transfers?.Count != 0);
Assert.IsTrue(userProductMapping.JsonDetailModel.Cars.Count == 1); Assert.IsTrue(userProductMapping.JsonDetailModel.Cars.Count == 1);
Assert.IsTrue(userProductMapping.JsonDetailModel.Cars[0].UserProductCarId == userProductCarId, "userProductMapping.JsonDetailModel.Cars[0].UserProductCarId == userProductCarId"); Assert.IsTrue(userProductMapping.JsonDetailModel.Cars[0].UserProductCarId == userProductCarId, "userProductMapping.JsonDetailModel.Cars[0].UserProductCarId == userProductCarId");
} }
@ -204,7 +197,8 @@ namespace TIAM.Database.Test
userProductMapping = await Dal.GetUserProductMappingByIdAsync(userProductMappingId, true); userProductMapping = await Dal.GetUserProductMappingByIdAsync(userProductMappingId, true);
Assert.IsNotNull(userProductMapping); Assert.IsNotNull(userProductMapping);
//userProductMapping.Permissions = 1;
Assert.IsNotNull(await Dal.UpdateUserProductMappingAsync(userProductMappingId, 1)); Assert.IsNotNull(await Dal.UpdateUserProductMappingAsync(userProductMappingId, 1));
userProductMapping = await Dal.GetUserProductMappingByIdAsync(userProductMappingId, true); userProductMapping = await Dal.GetUserProductMappingByIdAsync(userProductMappingId, true);
@ -225,57 +219,6 @@ namespace TIAM.Database.Test
#endregion UserProductMapping #endregion UserProductMapping
#region Product
[DataTestMethod]
[DataRow(["e24f6942-2210-47d7-8660-ace0ef302bae", "88b12e3d-bfec-462b-b1dc-1f4243ee7a00", "540271F6-C604-4C16-8160-D5A7CAFEDF00", "49c7805b-d8cd-4308-b1c5-7a54e5ee6287"])]
public async Task ProductCrudTest(string[] productIdCompanyIdUserIdUserToCompanyIdStrings)
{
var productId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[0]);
var companyId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[1]);
var userId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[2]); //test@tiam.hu
var userToCompanyId = Guid.Parse(productIdCompanyIdUserIdUserToCompanyIdStrings[3]);
await Dal.RemoveProductAsync(productId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
var product = new Product(productId, companyId, ProductType.Hotel, "Test unit product...", "Test unit product description...", 25000, null);
product.AddUser(userId, 1);
Assert.IsTrue(await Dal.AddProductAsync(product));
Assert.IsNotNull(product);
product = await Dal.GetProductByIdAsync(productId);
Assert.IsNotNull(product);
Assert.IsNotNull(product.Profile);
Assert.IsNotNull(product.Profile.Address);
Assert.IsTrue(product.UserProductMappings.Any(x=>x.UserId == userId && x.ProductId == productId));
Assert.IsTrue(product.Id == productId);
product.Price = 30000;
product.UserProductMappings[0].Permissions = 2;
Assert.IsNotNull(await Dal.UpdateProductAsync(product));
product = await Dal.GetProductByIdAsync(productId);
Assert.IsNotNull(product);
Assert.IsNotNull(product.UserProductMappings);
Assert.IsTrue((int)product.Price == 30000);
Assert.IsTrue(product.UserProductMappings[0].Permissions == 2);
var addressId = product.Profile.AddressId;
Assert.IsTrue(await Dal.RemoveProductAsync(product.Id)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
Assert.IsNull(await Dal.GetProfileByIdAsync(product.ProfileId));
Assert.IsNull(await Dal.GetAddressByIdAsync(addressId));
Assert.IsTrue((await Dal.GetUserProductMappingsByProductIdAsync(productId)).Count == 0);
product = await Dal.GetProductByIdAsync(productId);
Assert.IsNull(product); //a korábbi törlés miatt NULL kell legyen - J.
}
#endregion Product
[DataTestMethod] [DataTestMethod]
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")] [DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
[DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")] [DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")]
@ -290,14 +233,14 @@ namespace TIAM.Database.Test
NullValueHandling = NullValueHandling.Ignore NullValueHandling = NullValueHandling.Ignore
}; };
var userModel = Dal.GetUserModelDtoById<UserModelDto>(userId, false); var userModel = Dal.GetUserModelDtoById(userId);
var serializedUserModel = JsonConvert.SerializeObject(userModel, options); var serializedUserModel = JsonConvert.SerializeObject(userModel, options);
userModel = JsonConvert.DeserializeObject<UserModelDto>(serializedUserModel); userModel = JsonConvert.DeserializeObject<UserModelDto>(serializedUserModel);
Assert.IsNotNull(userModel); Assert.IsNotNull(userModel);
Assert.IsNotNull(userModel.UserDto); Assert.IsNotNull(userModel.UserDto);
Assert.IsNotNull(userModel.ProfileDto); Assert.IsNotNull(userModel.Profile);
Assert.IsTrue(userModel.Id == userId, "userModel.Id != userId"); Assert.IsTrue(userModel.Id == userId, "userModel.Id != userId");
@ -317,7 +260,7 @@ namespace TIAM.Database.Test
public void GetSerializedUserEntity_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString) public void GetSerializedUserEntity_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
{ {
var userId = Guid.Parse(userIdString); var userId = Guid.Parse(userIdString);
var userJson = Dal.GetUserJsonById(userId, false); var userJson = Dal.GetUserJsonById(userId);
Assert.IsFalse(userJson?.IsNullOrWhiteSpace()); Assert.IsFalse(userJson?.IsNullOrWhiteSpace());
@ -348,56 +291,9 @@ namespace TIAM.Database.Test
var users = JsonConvert.DeserializeObject<List<User>>(userJson); var users = JsonConvert.DeserializeObject<List<User>>(userJson);
Assert.IsNotNull(users); Assert.IsNotNull(users);
Assert.IsTrue(users.Count > 0); Assert.IsTrue(users.Count>0);
} }
#region Company
[DataTestMethod]
[DataRow(["8e6a4170-0e15-4f8a-bdd2-46f9dbc63b93", "540271F6-C604-4C16-8160-D5A7CAFEDF00", "49c7805b-d8cd-4308-b1c5-7a54e5ee6287"])]
public async Task CompanyCrudTest(string[] companyIdUserIdUserToCompanyIdStrings)
{
var companyId = Guid.Parse(companyIdUserIdUserToCompanyIdStrings[0]);
var userId = Guid.Parse(companyIdUserIdUserToCompanyIdStrings[1]); //test@tiam.hu
var userToCompanyId = Guid.Parse(companyIdUserIdUserToCompanyIdStrings[2]);
await Dal.RemoveCompanyAsync(companyId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
var company = new Company(companyId, "Test unit company...", null);
Assert.IsTrue(await Dal.AddCompanyAsync(company));
Assert.IsNotNull(company);
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNotNull(company);
Assert.IsTrue(company.UserToServiceProviders.Count == 0);
Assert.IsTrue(company.Id == companyId);
company.OwnerId = userId;
Assert.IsNotNull(await Dal.UpdateCompanyAsync(company));
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNotNull(company);
Assert.IsNotNull(company.UserToServiceProviders);
Assert.IsTrue(company.UserToServiceProviders.Any(x=>x.UserId == userId && x.ServiceProviderId == companyId));
company.CommissionPercent = 5;
Assert.IsNotNull(await Dal.UpdateCompanyAsync(company));
var addressId = company.Profile.AddressId;
Assert.IsTrue(await Dal.RemoveCompanyAsync(company.Id)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
Assert.IsNull(await Dal.GetProfileByIdAsync(company.ProfileId));
Assert.IsNull(await Dal.GetAddressByIdAsync(addressId));
Assert.IsTrue(Dal.GetProductsByServiceProviderId(companyId).Count == 0);
company = await Dal.GetCompanyByIdAsync(companyId);
Assert.IsNull(company); //a korábbi törlés miatt NULL kell legyen - J.
}
#endregion Company
#region Transfer #region Transfer
[DataTestMethod] [DataTestMethod]
[DataRow("6216f9fb-1dda-44bd-9d85-431f3cb09fde")] [DataRow("6216f9fb-1dda-44bd-9d85-431f3cb09fde")]
@ -407,37 +303,11 @@ namespace TIAM.Database.Test
var transfer = Dal.GetTransferById(transferId); var transfer = Dal.GetTransferById(transferId);
Assert.IsNotNull(transfer); Assert.IsNotNull(transfer);
//Assert.IsNotNull(transfer.UserProductMapping); Assert.IsNotNull(transfer.UserProductMapping);
Assert.IsNotNull(transfer.TransferToDrivers);
Assert.IsTrue(transfer.TransferToDrivers.Count > 0);
Assert.IsNotNull(transfer.TransferToDrivers[0].Car);
Assert.AreEqual(transfer.OrderId, 1);
Assert.IsTrue(transfer.Id == transferId, "transfer.Id != transferId"); Assert.IsTrue(transfer.Id == transferId, "transfer.Id != transferId");
} }
[DataTestMethod]
[DataRow(["4CBAED43-2465-4D99-84F1-C8BC6B7025F7", "71392CFD-FB9C-45C1-9540-7BE3782CF26A"])]
public async Task GetTransfersByDriver_ReturnsTransfers_WhenHasTransfers(string[] driverUserIdUserProductMappingIdString)
{
var driverUserId = Guid.Parse(driverUserIdUserProductMappingIdString[0]);
var userProductMappingId = Guid.Parse(driverUserIdUserProductMappingIdString[1]);
var transfers = await Dal.GetTransfersByUserProductMappingIdAsync(userProductMappingId);
Assert.IsNotNull(transfers);
Assert.IsTrue(transfers.Count > 0);
Assert.IsNotNull(transfers.All(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMappingId == userProductMappingId)));
var count = transfers.Count;
transfers = await Dal.GetTransfersByDriverUserIdAsync(driverUserId);
Assert.IsNotNull(transfers);
Assert.IsTrue(transfers.Count == count);
Assert.IsNotNull(transfers.All(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMappingId == userProductMappingId)));
}
[DataTestMethod] [DataTestMethod]
[DataRow("273EFE3C-D19F-4C2A-BF19-7397DC835C60")] [DataRow("273EFE3C-D19F-4C2A-BF19-7397DC835C60")]
public void GetTransferDestionationById_ReturnsTransferDestination_WhenHasAddressRelation(string transferDestinationIdString) public void GetTransferDestionationById_ReturnsTransferDestination_WhenHasAddressRelation(string transferDestinationIdString)
@ -455,43 +325,22 @@ namespace TIAM.Database.Test
} }
[DataTestMethod] [DataTestMethod]
//[DataRow("273EFE3C-D19F-4C2A-BF19-7397DC835C60")] [DataRow(["8f38f8e3-a92c-4979-88b1-dc812a82245f", "814b5495-c2e9-4f1d-a73f-37cd5d353078", "71392CFD-FB9C-45C1-9540-7BE3782CF26A"])]
//[DataRow("814b5495-c2e9-4f1d-a73f-37cd5d353078")] public async Task TransferCrudTest(string[] transferIdProductIdUserProductIdStrings)
[DataRow(["814b5495-c2e9-4f1d-a73f-37cd5d353078", "273EFE3C-D19F-4C2A-BF19-7397DC835C60"])]
public void GetTransferDestionationToProductById_ReturnsTransferDestinationToProduct_WhenHasTransferDestinationRelation(string[] productIdTransferDestinationIdString)
{ {
var productId = Guid.Parse(productIdTransferDestinationIdString[0]); var transferId = Guid.Parse(transferIdProductIdUserProductIdStrings[0]);
var transferDestinationId = Guid.Parse(productIdTransferDestinationIdString[1]); var productId = Guid.Parse(transferIdProductIdUserProductIdStrings[1]);
var userProductMappingId = Guid.Parse(transferIdProductIdUserProductIdStrings[2]);
var transferDestinationToProduct = Dal.GetTransferDestinationToProduct(productId, transferDestinationId);
Assert.IsNotNull(transferDestinationToProduct);
Assert.IsNotNull(transferDestinationToProduct.TransferDestination);
Assert.IsTrue(transferDestinationToProduct.TransferDestination.Id == transferDestinationId, "transferDestinationToProduct.TransferDestination.Id != transferDestinationId");
}
[DataTestMethod]
[DataRow(["8f38f8e3-a92c-4979-88b1-dc812a82245f", "814b5495-c2e9-4f1d-a73f-37cd5d353078", "71392CFD-FB9C-45C1-9540-7BE3782CF26A", "b3f51770-c821-4207-be2a-e622fed2a731"])]
public async Task TransferCrudTest(string[] transferIdProductIdUserProductIdCarIdStrings)
{
var userId = Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00"); //test@tiam.hu
var transferId = Guid.Parse(transferIdProductIdUserProductIdCarIdStrings[0]);
var productId = Guid.Parse(transferIdProductIdUserProductIdCarIdStrings[1]);
var userProductMappingId = Guid.Parse(transferIdProductIdUserProductIdCarIdStrings[2]);
var carId = Guid.Parse(transferIdProductIdUserProductIdCarIdStrings[3]);
var fromAddress = "Budapest, Liszt Ferenc tér"; var fromAddress = "Budapest, Liszt Ferenc tér";
var toAddress = "1211 Budapest, Kossuth Lajos utca 145"; var toAddress = "1211 Budapest, Kossuth Lajos utca 145";
//var userProductToCarId = Guid.Parse("97179a87-d99f-4f12-b7b2-75e21aaec6ab"); var userProductToCarId = Guid.Parse("97179a87-d99f-4f12-b7b2-75e21aaec6ab");
await Dal.RemoveTransferAsync(transferId); //kitöröljük a szemetet, ha korábbról bentmaradt - J. await Dal.RemoveTransferAsync(transferId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
var transfer = new Transfer var transfer = new Transfer
{ {
Id = transferId, Id = transferId,
UserId = userId,
ProductId = productId, ProductId = productId,
//ReferralProductId = productId, //ReferralProductId = productId,
Appointment = DateTime.UtcNow.AddDays(3), Appointment = DateTime.UtcNow.AddDays(3),
@ -500,51 +349,32 @@ namespace TIAM.Database.Test
ToAddress = toAddress, ToAddress = toAddress,
PassengerCount = 3, PassengerCount = 3,
Price = 20000, Price = 20000,
FirstName = "xyzFirstName_Test",
LastName = "xyzLastName_Test",
ContactEmail = "xyztest@gmail.hu",
ContactPhone = "+3671542771",
TransferStatusType = TransferStatusType.OrderConfirmed, TransferStatusType = TransferStatusType.OrderConfirmed,
}; };
//TransferStatusType.OrderSubmitted.GetDisplayName();
Assert.IsTrue(await Dal.AddTransferAsync(transfer)); Assert.IsTrue(await Dal.AddTransferAsync(transfer));
Assert.IsNotNull(transfer); Assert.IsNotNull(transfer);
transfer = Dal.GetTransferById(transferId); transfer = Dal.GetTransferById(transferId);
Assert.IsNotNull(transfer); Assert.IsNotNull(transfer);
//Assert.IsNull(transfer.UserProductMapping); Assert.IsNull(transfer.UserProductMapping);
Assert.IsTrue(transfer.OrderId > 0);
var car = Dal.GetCarById(carId); transfer.Payed = true;
Assert.IsNotNull(car); transfer.UserProductToCarId = userProductToCarId;
Assert.IsTrue(car.UserProductMappingId == userProductMappingId); transfer.UserProductMappingId = userProductMappingId;
var transferToDriver = new TransferToDriver(Guid.NewGuid(), transferId, userProductMappingId, carId, car.LicencePlate, 12000);
transfer.Paid = true;
//transfer.UserProductToCarId = userProductToCarId;
//transfer.UserProductMappingId = userProductMappingId;
transfer.TransferStatusType = TransferStatusType.AssignedToDriver; transfer.TransferStatusType = TransferStatusType.AssignedToDriver;
Assert.IsTrue(await Dal.UpdateTransferAsync(transfer, transferToDriver)); Assert.IsTrue(await Dal.UpdateTransferAsync(transfer));
transfer = Dal.GetTransferById(transferId); transfer = Dal.GetTransferById(transferId);
Assert.IsNotNull(transfer); Assert.IsNotNull(transfer);
//Assert.IsNotNull(transfer.UserProductMapping); Assert.IsNotNull(transfer.UserProductMapping);
Assert.IsNotNull(transfer.TransferToDrivers);
Assert.IsTrue(transfer.TransferToDrivers.Count > 0); Assert.IsTrue(transfer.Payed);
Assert.IsTrue(transfer.UserProductToCarId == userProductToCarId);
car = transfer.TransferToDrivers[0].Car;
Assert.IsNotNull(car);
Assert.IsTrue(car.Id == carId);
Assert.IsTrue(transfer.Paid);
//Assert.IsTrue(transfer.UserProductToCarId == userProductToCarId);
Assert.IsTrue(transfer.TransferStatusType == TransferStatusType.AssignedToDriver); Assert.IsTrue(transfer.TransferStatusType == TransferStatusType.AssignedToDriver);
Assert.IsTrue(transfer.Id == transferId, "transfer.Id != transferId"); Assert.IsTrue(transfer.Id == transferId, "transfer.Id != transferId");
@ -554,48 +384,6 @@ namespace TIAM.Database.Test
Assert.IsNull(transfer); //a korábbi törlés miatt NULL kell legyen - J. Assert.IsNull(transfer); //a korábbi törlés miatt NULL kell legyen - J.
} }
[DataTestMethod]
[DataRow(["069089cd-66d4-4f0d-851b-2eea14fa62a4", "be709d9b-87dc-4c94-bf9e-d6254db3fa3e"])]
public async Task TransferDestinationCrudTest(string[] transferDestIdAddressIdStrings)
{
var transferDestId = Guid.Parse(transferDestIdAddressIdStrings[0]);
var addressId = Guid.Parse(transferDestIdAddressIdStrings[1]);
await Dal.RemoveTransferDestinationAsync(transferDestId, true); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
var transferDest = TestHelper.CreateTransferDestination(transferDestId, addressId);
Assert.IsTrue(await Dal.AddTransferDestinationAsync(transferDest));
Assert.IsNotNull(transferDest);
transferDest = Dal.GetTransferDestinationById(transferDestId);
Assert.IsNotNull(transferDest);
Assert.IsNotNull(transferDest.Address);
var modifiedAddress = "modified; " + transferDest.Address.AddressText;
transferDest.Price = 20000;
transferDest.Address.AddressText = modifiedAddress;
Assert.IsTrue(await Dal.UpdateTransferDestinationAsync(transferDest));
transferDest = Dal.GetTransferDestinationById(transferDestId);
Assert.IsNotNull(transferDest);
Assert.IsNotNull(transferDest.Address);
Assert.IsTrue(transferDest.Price == 20000);
Assert.IsTrue(transferDest.Address.AddressText == modifiedAddress);
Assert.IsTrue(transferDest.Id == transferDestId, "transferDest.Id != transferDestId");
Assert.IsTrue(await Dal.RemoveTransferDestinationAsync(transferDestId, true)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
transferDest = Dal.GetTransferDestinationById(transferDestId);
Assert.IsNull(transferDest); //a korábbi törlés miatt NULL kell legyen - J.
}
#endregion Transfer #endregion Transfer
#region EmailMessage #region EmailMessage
@ -619,10 +407,10 @@ namespace TIAM.Database.Test
var userId = Guid.Parse(userIdUserProductMappingIdString[0]); var userId = Guid.Parse(userIdUserProductMappingIdString[0]);
var userProductMappingId = Guid.Parse(userIdUserProductMappingIdString[1]); var userProductMappingId = Guid.Parse(userIdUserProductMappingIdString[1]);
var emailMessages = await Dal.GetEmailMessagesByUserIdOrUpmId(userId, userProductMappingId); var emailMessages = await Dal.GetEmailMessagesAsync(userId, userProductMappingId);
Assert.IsNotNull(emailMessages); Assert.IsNotNull(emailMessages);
Assert.IsTrue(emailMessages.Count > 0); Assert.IsTrue(emailMessages.Count > 0);
Assert.IsTrue(emailMessages.All(x => x.Recipients.Any(recipient => recipient.RecipientId == userId || recipient.RecipientId == userProductMappingId))); Assert.IsTrue(emailMessages.All(x => x.Recipients.Any(recipient => recipient.RecipientId == userId || recipient.RecipientId == userProductMappingId)));
} }
@ -636,15 +424,14 @@ namespace TIAM.Database.Test
var contextId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[2]); var contextId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[2]);
var senderEmail = emailIdSenderIdContextIdSenderEmailRecipientIdStrings[3]; var senderEmail = emailIdSenderIdContextIdSenderEmailRecipientIdStrings[3];
var recipientId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[4]); var recipientId = Guid.Parse(emailIdSenderIdContextIdSenderEmailRecipientIdStrings[4]);
var recipientEmail = "info@touriam.com";
var subject = "Transfer - Budapest, Liszt Ferenc tér"; var subject = "Transfer - Budapest, Liszt Ferenc tér";
var text = "1211 Budapest, Kossuth Lajos utca 145"; var text = "1211 Budapest, Kossuth Lajos utca 145";
await Dal.RemoveEmailMessageAsync(emailMessageId); //kitöröljük a szemetet, ha korábbról bentmaradt - J. await Dal.RemoveEmailMessageAsync(emailMessageId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
var emailMessage = new EmailMessage(emailMessageId, senderId, contextId, subject, text, senderEmail); var emailMessage = new EmailMessage(emailMessageId, senderId, contextId, subject, text, senderEmail);
emailMessage.Recipients.Add(new EmailRecipient(id: Guid.NewGuid(), recipientId, emailMessageId, recipientEmail)); emailMessage.Recipients.Add(new EmailRecipient(id: Guid.NewGuid(), recipientId, emailMessageId));
Assert.IsTrue(await Dal.AddEmailMessageAsync(emailMessage)); Assert.IsTrue(await Dal.AddEmailMessageAsync(emailMessage));
@ -657,7 +444,7 @@ namespace TIAM.Database.Test
var modifiedText = "modifiedText"; var modifiedText = "modifiedText";
emailMessage.Text = modifiedText; emailMessage.Text = modifiedText;
Assert.IsTrue(await Dal.UpdateEmailMessageAsync(emailMessage)); Assert.IsTrue(await Dal.UpdateEmailMessageAsync(emailMessage));
@ -678,3 +465,4 @@ namespace TIAM.Database.Test
#endregion EmailMessage #endregion EmailMessage
} }
} }

View File

@ -1,11 +1,13 @@
using AyCode.Database.Tests; using AyCode.Database.Tests;
using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbContexts; using TIAM.Database.DbContexts;
using TIAM.Database.DbContexts.Transfers;
using TIAM.Database.DbContexts.Users;
namespace TIAM.Database.Test namespace TIAM.Database.Test
{ {
[TestClass] [TestClass]
public class DatabaseTestBase : AcDatabaseTestBase<DbContextBase> public class DatabaseTest : AcDatabaseTestBase<DbContextBase>
{ {
[TestInitialize] [TestInitialize]
public void Setup() public void Setup()
@ -17,8 +19,5 @@ namespace TIAM.Database.Test
public void TearDown() public void TearDown()
{ {
} }
[TestMethod]
public override void DatabaseExistsTest() => base.DatabaseExistsTest();
} }
} }

View File

@ -10,29 +10,15 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="appsettings.json" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
</ItemGroup> <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.1" />
<ItemGroup> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<Content Include="appsettings.json"> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <PackageReference Include="Moq" Version="4.20.70" />
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> <PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> <PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
</Content> <PackageReference Include="coverlet.collector" Version="6.0.0">
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@ -1,51 +0,0 @@
using TIAM.Entities.Addresses;
using TIAM.Entities.Transfers;
namespace TIAM.Database.Test;
public static class TestHelper
{
public static TransferDestinationToProduct CreateTransferDestinationToProduct(Guid transferDestinationToProductId, Guid transferDestId, Guid productId)
{
var transferDestinationToProduct = new TransferDestinationToProduct();
transferDestinationToProduct.Id = transferDestinationToProductId;
transferDestinationToProduct.ProductId = productId;
transferDestinationToProduct.TransferDestinationId = transferDestId;
transferDestinationToProduct.Price = 5000;
transferDestinationToProduct.Price2 = 6000;
transferDestinationToProduct.Price3 = 8000;
transferDestinationToProduct.ProductCommis = 0.1d;
return transferDestinationToProduct;
}
public static TransferDestination CreateTransferDestination(Guid transferDestId, Guid addressId)
{
var name = "Liszt Ferenc repülőtér";
var address = "Budapest, Liszt Ferenc tér";
var transferDest = new TransferDestination
{
Id = transferDestId,
AddressId = addressId,
Name = name,
Description = name + "description",
Price = 15000,
//Price2 = 21000,
//Price3 = 23000,
//PriceType = PriceType.Fix,
AddressString = address,
Address = new Address
{
Id = addressId,
AddressText = address,
IsValid = false,
IsHelper = false,
Latitude = null,
Longitude = null
}
};
return transferDest;
}
}

View File

@ -1,39 +1,32 @@
using AyCode.Database.Tests.Users; using AyCode.Database.DataLayers;
using AyCode.Database.Tests;
using AyCode.Database.Tests.Users;
using Microsoft.EntityFrameworkCore;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Newtonsoft.Json; using Newtonsoft.Json;
using AyCode.Core.Helpers; using System.Text.Json.Serialization;
using System.Text.Json;
using TIAM.Database.DataLayers.Users; using TIAM.Database.DataLayers.Users;
using TIAM.Database.DbContexts.Users; using TIAM.Database.DbContexts.Users;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using AyCode.Interfaces.Users.Dtos;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Addresses; using TIAM.Entities.Addresses;
using TIAM.Entities.Emails;
namespace TIAM.Database.Test namespace TIAM.Database.Test
{ {
[TestClass] [TestClass]
public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, Profile, UserToken, Company, UserToCompany, Address, EmailMessage> public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider, Address>
{ {
//private Guid _registerUserId = Guid.Parse("1f7e0591-330b-463b-81ad-d01f2e65e23e"); private Mock<UserDbContext> _mockContext;
//private const string RegisterEmail = "qwerty@xxxxx.com";
//private const string RegisterPassword = "elem'r";
//private const string LoginEmail = "asdfsdf@ggggg.hu";
//private const string LoginPassword = "alad'r";
//private WebAssemblyHostConfiguration _configuration = new();
//private Mock<UserDbContext> _mockContext;
[TestInitialize] [TestInitialize]
public void TestInitialize() public void TestInitialize()
{ {
//AppSettingsConfiguration = InitAppSettingsConfiguration();
//_configuration["JWT:Key"] = "Cee4400-rDMFkVvHPufyLDSzbfu2grgRhpepos299IhTLOXsljkcpt3yUR4RRjPQ";
//_configuration["JWT:Audience"] = "http://localhost:5000";
//_configuration["JWT:Issuer"] = "http://localhost:5000";
//var options = new DbContextOptionsBuilder<UserDbContext>() //var options = new DbContextOptionsBuilder<UserDbContext>()
// .UseInMemoryDatabase(databaseName: "UserDatabase") // .UseInMemoryDatabase(databaseName: "UserDatabase")
// .Options; // .Options;
@ -46,100 +39,27 @@ namespace TIAM.Database.Test
//_userDal = new UserDal(_mockContext.Object); //_userDal = new UserDal(_mockContext.Object);
} }
//[TestMethod] [TestMethod]
public async Task ConvertOldPassword()
{
//var loginService = new LoginService(Dal, AppSettingsConfiguration);
var users = Dal.Context.Users.ToList();
foreach (var user in users)
{
if (user.Password.Contains("$bcrypt$v=1$salt=")) continue;
user.Password = PasswordHasher.HashPassword(user.Password, PasswordHasher.GenerateDynamicSalt(user.Id));
await Dal.UpdateUserAsync(user);
}
}
//[DataTestMethod]
//public async Task RegisterUser_ReturnsUser_WhenUserExist()
//{
// //var a = TiamConst.ProjectIdString;
// await Dal.RemoveUserAsync(_registerUserId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
// var loginService = new LoginService(Dal, AcEnv.AppConfiguration);
// var errorCode = await loginService.RegistrationAsync(_registerUserId, RegisterEmail, RegisterPassword, null);
// Assert.IsTrue(errorCode == AcErrorCode.Unset);
// var user = Dal.GetUserByEmail(RegisterEmail, false);
// Assert.IsNotNull(user);
// Assert.IsNotNull(user.Profile);
// Assert.IsNotNull(user.Profile.Address);
// await Dal.RemoveUserAsync(user); //kitöröljük a szemetet - J.
//}
//[DataTestMethod]
//[DataRow([LoginEmail, LoginPassword])]
//public void LoginUser_ReturnsUser_WhenUserExist()
//{
// //var a = TiamConst.ProjectIdString;
// var loginService = new LoginService(Dal, AcEnv.AppConfiguration);
// #region Valid email+password test
// var loggedInModel = loginService.Login(LoginEmail, LoginPassword);
// Assert.IsNotNull(loggedInModel);
// Assert.IsNotNull(loggedInModel.LoggedInUser);
// Assert.IsNotNull(loginService.LoggedInModel?.LoggedInUser);
// Assert.IsTrue(loggedInModel.LoginErrorCode == AcErrorCode.Unset, $"errorCode: {loggedInModel.LoginErrorCode}");
// Assert.IsTrue(loggedInModel.IsLoggedIn, $"loggedInModel.IsLoggedIn == false; errorCode: {loggedInModel.LoginErrorCode}");
// Assert.IsTrue(string.Equals(loggedInModel.LoggedInUser.EmailAddress, LoginEmail, StringComparison.CurrentCultureIgnoreCase));
// #endregion Valid email+password test
// #region Wrong email test
// loggedInModel = loginService.Login("gffsdgdfg@gu.hu", LoginPassword);
// Assert.IsNotNull(loggedInModel);
// Assert.IsFalse(loggedInModel.IsLoggedIn);
// Assert.IsTrue(loggedInModel.LoginErrorCode == AcErrorCode.WrongLoginData);
// #endregion Wrong email test
// #region Wrong password test
// loggedInModel = loginService.Login(LoginEmail, "fsdgfsdg");
// Assert.IsNotNull(loggedInModel);
// Assert.IsFalse(loggedInModel.IsLoggedIn);
// Assert.IsTrue(loggedInModel.LoginErrorCode == AcErrorCode.WrongLoginData);
// #endregion Wrong password test
//}
[DataTestMethod]
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")] [DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
public override void AcBase_GetUserById_ReturnsUser_WhenUserExists(string userIdString) public void GetUserById_ReturnsUser_WhenUserAndRelationsExists(string userIdString)
{ {
var user = AcBase_GetUserById(userIdString); var user = AcBase_GetUserById_ReturnsUser_WhenUserExists(userIdString);
Assert.IsTrue(user.ServiceProviders.Count > 0); Assert.IsTrue(user.ServiceProviders.Count > 0);
Assert.IsTrue(user.UserToServiceProviders.Count > 0); Assert.IsTrue(user.UserToServiceProviders.Count > 0);
} }
[DataTestMethod] [TestMethod]
[DataRow("test@tiam.hu")] [DataRow("test@tiam.hu")]
public override void AcBase_GetUserByEmail_ReturnsUser_WhenUserExists(string email) public void GetUserByEmail_ReturnsUser_WhenUserAndRelationsExists(string email)
{ {
var user = AcBase_GetUserByEmail(email); var user = AcBase_GetUserByEmail_ReturnsUser_WhenUserExists(email);
Assert.IsTrue(user.ServiceProviders.Count > 0); Assert.IsTrue(user.ServiceProviders.Count > 0);
Assert.IsTrue(user.UserToServiceProviders.Count > 0); Assert.IsTrue(user.UserToServiceProviders.Count > 0);
} }
[DataTestMethod] [TestMethod]
[DataRow("test@tiam.hu")] [DataRow("test@tiam.hu")]
public async Task GetUserByEmailAsync_ReturnsUser_WhenUserAndRelationsExists(string email) public async Task GetUserByEmailAsync_ReturnsUser_WhenUserAndRelationsExists(string email)
{ {
@ -149,12 +69,7 @@ namespace TIAM.Database.Test
Assert.IsTrue(user.UserToServiceProviders.Count > 0); Assert.IsTrue(user.UserToServiceProviders.Count > 0);
} }
[DataTestMethod] [TestMethod]
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
public override void AcBase_GetUserModelDtoDetailById_ReturnsUser_WhenUserExists(string userIdString)
=> base.AcBase_GetUserModelDtoDetailById_ReturnsUser_WhenUserExists(userIdString);
[DataTestMethod]
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")] [DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
[DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")] [DataRow("dcf451d2-cc4c-4ac2-8c1f-da00041be1fd")]
[DataRow("ac612aa8-863b-4b4f-9d63-f5d261b5c5f9")] [DataRow("ac612aa8-863b-4b4f-9d63-f5d261b5c5f9")]
@ -168,14 +83,14 @@ namespace TIAM.Database.Test
NullValueHandling = NullValueHandling.Ignore NullValueHandling = NullValueHandling.Ignore
}; };
var userModel = await Dal.GetUserModelDtoByIdAsync<UserModelDto>(userId, false).ConfigureAwait(false); var userModel = await Dal.GetUserModelDtoByIdAsync(userId).ConfigureAwait(false);
var serializedUserModel = JsonConvert.SerializeObject(userModel, options); var serializedUserModel = JsonConvert.SerializeObject(userModel, options);
userModel = JsonConvert.DeserializeObject<UserModelDto>(serializedUserModel); userModel = JsonConvert.DeserializeObject<UserModelDto>(serializedUserModel);
Assert.IsNotNull(userModel); Assert.IsNotNull(userModel);
Assert.IsNotNull(userModel.UserDto); Assert.IsNotNull(userModel.UserDto);
Assert.IsNotNull(userModel.ProfileDto); Assert.IsNotNull(userModel.Profile);
if (userId != Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00")) return; //csak az "540271F6.."-nek van product-ja! - J. if (userId != Guid.Parse("540271F6-C604-4C16-8160-D5A7CAFEDF00")) return; //csak az "540271F6.."-nek van product-ja! - J.
@ -186,12 +101,6 @@ namespace TIAM.Database.Test
Assert.IsTrue(userModel.UserToServiceProviders.Count > 0); Assert.IsTrue(userModel.UserToServiceProviders.Count > 0);
} }
[DataTestMethod]
[DataRow(["e31044d7-1771-4a32-8dd9-6f9853ed53c6", "0a831191-70a3-4504-9ec4-c5902affaba7", "8eed080c-d2ce-4cc3-bcfe-2268c220bba7", "addUser_test9432@tiam.hu"])]
public override async Task AcBase_AddUserTest(string[] userIdProfileIdAddressIdEmailStrings)
=> await base.AcBase_AddUserTest(userIdProfileIdAddressIdEmailStrings);
//[TestMethod] //[TestMethod]
//[DataRow("test@tiam.hu")] //[DataRow("test@tiam.hu")]
//public async Task GetUserByEmailAsync_ReturnsUser_WhenUserExists(string email) //public async Task GetUserByEmailAsync_ReturnsUser_WhenUserExists(string email)

View File

@ -1,43 +0,0 @@
{
"ConnectionStrings": {
"DeveloperDbConnection": "Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Trusted_Connection=false;Encrypt=false;TrustServerCertificate=True;Connect Timeout=200;User ID=Anata_Development_Team;Password=v6f_?xNfg9N1;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"JWT": {
"Key": "Cee4400-rDMFkVvHPufyLDSzbfu2grgRhpepos299IhTLOXsljkcpt3yUR4RRjPQ",
"Issuer": "http://localhost:5000",
"Audience": "http://localhost:5000"
},
"SendGrid": {
//"Key": "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"
"Key": "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"
},
"AyCode": {
"ProjectId": "684f34d1-163a-4077-918f-a9d9df5ce789",
"Urls": {
"BaseUrl": "https://localhost:7116",
"ApiBaseUrl": "https://localhost:7116"
},
"Logger": {
"AppType": "Server",
"LogLevel": "Detail",
"LogWriters": [
{
"LogLevel": "Detail",
"LogWriterType": "TIAM.Core.Loggers.ConsoleLogWriter, TIAM.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
},
{
"LogLevel": "Detail",
"LogWriterType": "TIAM.Database.DbLogItemWriter, TIAM.Database, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
}
]
}
}
}

View File

@ -1,40 +1,26 @@
using System.Linq.Expressions; using System.Security.Cryptography.X509Certificates;
using AyCode.Core.Extensions;
using AyCode.Core.Loggers;
using AyCode.Core.Server.Loggers;
using AyCode.Database.DbSets.Messages;
using AyCode.Database.DbSets.Users; using AyCode.Database.DbSets.Users;
using AyCode.Models.Enums; using AyCode.Models.Enums;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using AyCode.Database.DbSets.Addresses; using Microsoft.Extensions.DependencyInjection;
using AyCode.Database.DbSets.Companies; using TIAM.Core;
//using TIAM.Database.DataLayers.ServiceProviders; //using TIAM.Database.DataLayers.ServiceProviders;
using TIAM.Database.DbContexts.Admins; using TIAM.Database.DbContexts.Admins;
using TIAM.Database.DbSets.Emails;
using TIAM.Database.DbSets.Permissions; using TIAM.Database.DbSets.Permissions;
using TIAM.Database.DbSets.Products; using TIAM.Database.DbSets.Products;
using TIAM.Database.DbSets.Transfers; using TIAM.Database.DbSets.Transfers;
using TIAM.Database.DbSets.Users; using TIAM.Database.DbSets.Users;
using TIAM.Entities.Addresses;
using TIAM.Entities.Drivers; using TIAM.Entities.Drivers;
using TIAM.Entities.Emails; using TIAM.Entities.Emails;
using TIAM.Entities.Permissions; using TIAM.Entities.Permissions;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.TransferDestinations;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Products; using TIAM.Models.Dtos.Products;
using AyCode.Database.DbSets.Profiles;
using DevExpress.Data.Filtering;
using DevExpress.Data.Linq;
using DevExpress.Data.Linq.Helpers;
using TIAM.Database.DbSets.Drivers;
using AyCode.Entities.Server.LogItems;
using AyCode.Interfaces.Entities;
using TIAM.Models;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using TIAM.Models.PageViewModels;
using EmailMessage = TIAM.Entities.Emails.EmailMessage;
namespace TIAM.Database.DataLayers.Admins namespace TIAM.Database.DataLayers.Admins
{ {
@ -44,229 +30,41 @@ namespace TIAM.Database.DataLayers.Admins
{ {
} }
//TODO: ezt meg a Messages-eket átbuherálni a UserDal-ra... - J.
public async Task<SiteViewModel> GetSiteViewModelByUserId(Guid userId)
{
var messages = await GetEmailMessagesByUserId(userId, true);
return new SiteViewModel(messages);
}
#region Car
public Task<List<Car>> GetAllCarsAsync() => SessionAsync(ctx => ctx.Cars.OrderBy(x => x.Manufacture).ThenBy(x => x.CarModel).ToList());
public Task<List<Car>> GetAllCarsbyProductIdAsync(Guid productId) => SessionAsync(ctx => ctx.Cars.Where(x => x.UserProductMapping.ProductId == productId).OrderBy(x => x.Manufacture).ThenBy(x => x.CarModel).ToList());
public Car? GetCarById(Guid carId) => Session(ctx => ctx.Cars.FirstOrDefault(x => x.Id == carId));
public List<Car> GetCarByUserProductMappingId(Guid userProductMappingId) => Session(ctx => ctx.Cars.Where(x => x.UserProductMappingId == userProductMappingId).ToList());
public Task<List<Car>> GetCarsByUserProductMappingIdAsync(Guid userProductMappingId) => SessionAsync(ctx => ctx.Cars.Where(x => x.UserProductMappingId == userProductMappingId).ToList());
public Task<bool> AddCarAsync(Car car) => TransactionAsync(ctx => ctx.Cars.Add(car).State == EntityState.Added);
public Task<Car?> UpdateCarAsync(Car car) => UpdateSafeAsync(car);
public Task<bool> RemoveCarAsync(Car car) => TransactionAsync(ctx => ctx.Cars.Remove(car).State == EntityState.Deleted);
#endregion Car
#region Transfer #region Transfer
public TransferDestination? GetTransferDestinationById(Guid transferDestinationId, bool autoInclude = false) => Session(ctx=>ctx.GetTransferDestinationById(transferDestinationId));
public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)?.ToJson());
public Task<List<Transfer>> GetTransfersByFilterAsync(CriteriaOperator criteriaOperator) => SessionAsync(ctx => (ctx.GetTransfers().AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator) as IQueryable<Transfer>)!.OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList()); public Transfer? GetTransferById(Guid transferId, bool autoInclude = false) => Session(ctx => ctx.GetTransferById(transferId, autoInclude));
public Task<List<Transfer>> GetTransfersByDriverUserIdAsync(Guid driverUserId) => SessionAsync(ctx => ctx.GetTransfersByDriverUserId(driverUserId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList()); public string? GetTransferJsonById(Guid transferId, bool autoInclude = false) => Session(ctx => ctx.GetTransferById(transferId, autoInclude)?.ToJson());
public Task<List<Transfer>> GetTransfersByProductIdAsync(Guid productId) => SessionAsync(ctx => ctx.GetTransfersByProductId(productId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
public Task<List<Transfer>> GetTransfersByUserProductMappingIdAsync(Guid userProductMappingId) => SessionAsync(ctx => ctx.GetTransfersByUserProductMappingId(userProductMappingId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
/// <summary>
///
/// </summary>
/// <param name="driverId">UserProductMappingId</param>
/// <returns></returns>
public Task<DriverManageTransfersPageModel> GetDriverManageTransfersPageModelByDriverId(Guid driverId) => SessionAsync(ctx =>
{
var transfers = ctx.GetTransfersByUserProductMappingId(driverId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId);
var unreadMessagesCount = GetTransfersMessagesByDriverIdInnerAsync(ctx, driverId)?.Count(x => !x.IsReaded) ?? 0;
return new DriverManageTransfersPageModel(transfers, unreadMessagesCount);
});
public Task<List<Transfer>> GetTransfersAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
public Task<string> GetTransfersJsonAsync() => SessionAsync(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson());
public Task<List<Transfer>> GetTransfersByUserIdAsync(Guid userId) => SessionAsync(ctx => ctx.GetTransfersByUserId(userId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList());
public Task<string> GetTransfersByUserIdJsonAsync(Guid userId) => SessionAsync(ctx => ctx.GetTransfersByUserId(userId).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson());
public string GetTransfersJson() => Session(ctx => ctx.GetTransfers().OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToJson());
public Transfer? GetTransferById(Guid transferId) => Session(ctx => ctx.GetTransferById(transferId));
public Task<Transfer?> GetTransferByIdAsync(Guid transferId) => SessionAsync(ctx => ctx.GetTransferById(transferId));
public string? GetTransferJsonById(Guid transferId) => Session(ctx => ctx.GetTransferById(transferId)?.ToJson());
public Task<bool> AddTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.AddTransfer(transfer));
public Task<Transfer?> UpdateTransferAsync(Transfer transfer) => UpdateSafeAsync(transfer, (ctx, safeTransfer) => ctx.UpdateTransfer(safeTransfer));
//public async Task<Transfer?> UpdateTransferAsync(Transfer transfer)
//{
// Transfer? entity = null;
// var result = await TransactionAsync(ctx =>
// {
// entity = ctx.Set<Transfer>().AsNoTracking().FirstOrDefault(e => e.Id == transfer.Id);
// if (entity == null) return false;
// ctx.Entry(entity).State = EntityState.Detached;
// ctx.Entry(entity).CurrentValues.SetValues(transfer);
// return ctx.UpdateTransfer(entity);
// //foreach (var entityEntry in ctx.ChangeTracker.Entries())
// //{
// // if (entityEntry.Entity is not Transfer)
// // entityEntry.State = EntityState.Unchanged;
// //}
// //var existingTransfer = ctx.Transfers.Local.SingleOrDefault(o => o.Id == transfer.Id);
// //if (existingTransfer != null)
// // ctx.Entry(existingTransfer).State = EntityState.Detached;
// //var existingUsers = ctx.Users.Local.Where(o => transfer.TransferToDrivers.Any(x => x.UserProductMapping.UserId == o.Id)).ToList();
// //foreach (var existingUser in existingUsers)
// // ctx.Entry(existingUser).State = EntityState.Detached;
// //transfer.TransferToDrivers = null!;
// //return ctx.UpdateTransfer(transfer);
// });
// return result ? entity : null;
//}
public Task<bool> UpdateTransferAsync(Transfer transfer, TransferToDriver transferToDriver) => UpdateTransferAsync(transfer, [transferToDriver]);
public Task<bool> UpdateTransferAsync(Transfer transfer, List<TransferToDriver> transferToDrivers)
=> TransactionAsync(ctx =>
{
ctx.AddRange(transferToDrivers);
ctx.SaveChanges();
return ctx.UpdateTransfer(transfer);
});
public Task<bool> RemoveTransferAsync(Transfer transfer) => RemoveTransferAsync(transfer.Id);
public Task<bool> RemoveTransferAsync(Guid transferId) => TransactionAsync(ctx => ctx.RemoveTransfer(transferId));
public Task<bool> AddTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.AddTransfer(transfer) && ctx.SaveChanges() > 0);
public Task<bool> UpdateTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.UpdateTransfer(transfer) && ctx.SaveChanges() > 0);
public Task<bool> RemoveTransferAsync(Transfer transfer) => TransactionAsync(ctx => ctx.RemoveTransfer(transfer) && ctx.SaveChanges() > 0);
public Task<bool> RemoveTransferAsync(Guid transferId) => TransactionAsync(ctx => ctx.RemoveTransfer(transferId) && ctx.SaveChanges() > 0);
#endregion Transfer #endregion Transfer
#region TransferDestination
public Task<List<TransferDestination>> GetTransferDestinationsAsync() => SessionAsync(ctx => ctx.GetTransferDestinations().ToList());
public TransferDestination? GetTransferDestinationById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId));
public Task<TransferDestination?> GetTransferDestinationByIdAsync(Guid transferDestinationId) => SessionAsync(ctx => ctx.GetTransferDestinationById(transferDestinationId));
public Task<List<TransferDestination>> GetPublicTransferDestinationsAsync(Guid productId) => SessionAsync(ctx => ctx.GetTransferDestinations().Where(x => !x.ProductId.HasValue || x.ProductId == productId).ToList());
public Task<bool> AddTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.AddTransferDestination(transferDestination));
public Task<bool> UpdateTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.UpdateTransferDestination(transferDestination));
public Task<bool> RemoveTransferDestinationAsync(TransferDestination transferDestination, bool removeAddress) => RemoveTransferDestinationAsync(transferDestination.Id, removeAddress);
public Task<bool> RemoveTransferDestinationAsync(Guid transferDestinationId, bool removeAddress) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestinationId, removeAddress));
#endregion TransferDestination
#region TransferToDriver
public Task<TransferToDriver?> GetTransferToDriverByIdAsync(Guid transferToDriverId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriverById(transferToDriverId, autoInclude));
public Task<List<TransferToDriver>> GetTransferToDriversByUpmId(Guid upmId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriversByUpmId(upmId, autoInclude).ToList());
public Task<List<TransferToDriver>> GetTransferToDriversByTransferIdAsync(Guid transferId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriversByTransferId(transferId, autoInclude).ToList());
public Task<bool> AddTransferToDriverAsync(TransferToDriver transferToDriver) => TransactionAsync(ctx => ctx.AddTransferToDriver(transferToDriver));
public Task<TransferToDriver?> UpdateTransferToDriverAsync(TransferToDriver transferToDriver)
=> UpdateSafeAsync(transferToDriver, (ctx, safeTransferToDriver) => ctx.UpdateTransferToDriver(safeTransferToDriver));
//public async Task<TransferToDriver?> UpdateTransferToDriverAsync(TransferToDriver transferToDriver)
//{
// var transferToDriverId = transferToDriver.Id;
// TransferToDriver transferToDriver2 = null!;
// var result = await TransactionAsync(ctx =>
// {
// transferToDriver2 = ctx.TransferToDrivers.FirstOrDefault(x => x.Id == transferToDriverId)!;
// transferToDriver2.CarId = transferToDriver.CarId;
// transferToDriver2.LicencePlate = transferToDriver.LicencePlate;
// transferToDriver2.UserProductMappingId = transferToDriver.UserProductMappingId;
// transferToDriver2.TransferId = transferToDriver.TransferId;
// transferToDriver2.Price = transferToDriver.Price;
// return ctx.TransferToDrivers.Update(transferToDriver2).State == EntityState.Modified;
// });
// return result ? transferToDriver2 : null;
//}
public Task<bool> RemoveTransferToDriverAsync(TransferToDriver transferToDriver) => TransactionAsync(ctx => ctx.RemoveTransferToDriver(transferToDriver.Id));
#endregion TransferToDriver
#region Drivers
public Task<List<UserProductMapping>> GetAllDriversAsync(bool autoInclude = true) => SessionAsync(ctx => ctx.GetAllDrivers(autoInclude).ToList());
public Task<List<UserProductMapping>> GetAllDriversByProductIdAsync(Guid productId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetAllDriversByProductId(productId, autoInclude).ToList());
#endregion Drivers
#region TransferDestinationToProduct
public TransferDestinationToProduct? GetTransferDestinationToProductById(Guid transferDestinationToProductId) => Session(ctx => ctx.GetTransferDestinationToProductById(transferDestinationToProductId));
public Task<TransferDestinationToProduct?> GetTransferDestinationToProductByIdAsync(Guid transferDestinationToProductId) => SessionAsync(ctx => ctx.GetTransferDestinationToProductById(transferDestinationToProductId));
public string? GetTransferDestinationToProductJsonById(Guid transferDestinationToProductId) => Session(ctx => ctx.GetTransferDestinationToProductById(transferDestinationToProductId)?.ToJson());
public TransferDestinationToProduct? GetTransferDestinationToProduct(Guid productId, Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationToProduct(productId, transferDestinationId));
public Task<List<TransferDestinationToProduct>> GetTransferDestinationToProducts() => SessionAsync(ctx => ctx.GetTransferDestinationToProducts().ToList());
public Task<List<TransferDestinationToProduct>> GetTransferDestinationToProductsByProductId(Guid productId) => SessionAsync(ctx => ctx.GetTransferDestinationToProductsByProductId(productId).ToList());
public Task<List<TransferDestinationToProduct>> GetTransferDestinationToProductsByTransferDestinationId(Guid transferDestinationId) => SessionAsync(ctx => ctx.GetTransferDestinationToProductsByTransferDestinationId(transferDestinationId).ToList());
public string? GetTransferDestinationToProductJson(Guid productId, Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationToProduct(productId, transferDestinationId)?.ToJson());
public Task<bool> AddTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => TransactionAsync(ctx => ctx.AddTransferDestinationToProduct(transferDestinationToProduct));
public Task<bool> UpdateTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => TransactionAsync(ctx => ctx.UpdateTransferDestinationToProduct(transferDestinationToProduct));
public Task<bool> RemoveTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => RemoveTransferDestinationToProductAsync(transferDestinationToProduct.Id);
public Task<bool> RemoveTransferDestinationToProductAsync(Guid transferDestinationToProductId) => TransactionAsync(ctx => ctx.RemoveTransferDestinationToProduct(transferDestinationToProductId));
#endregion TransferDestinationToProduct
public User? GetUserById(Guid userId, bool autoInclude = false) => Session(ctx => ctx.GetUserById(userId, autoInclude)); public User? GetUserById(Guid userId, bool autoInclude = false) => Session(ctx => ctx.GetUserById(userId, autoInclude));
public User? GetUserByEmail(string email, bool autoInclude = false) => Session(ctx => ctx.GetUserByEmail(email, autoInclude)); public User? GetUserByEmail(string email, bool autoInclude = false) => Session(ctx => ctx.GetUserByEmail(email, autoInclude));
public TUserModelDto? GetUserModelDtoById<TUserModelDto>(Guid userId, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase public UserModelDto? GetUserModelDtoById(Guid userId) => Session(ctx => ctx.GetUserModelDtoById(userId));
=> Session(ctx => ctx.GetUserModelDtoById<TUserModelDto, User>(userId, onlyConfirmed)); public Task<UserModelDto?> GetUserModelDtoByIdAsync(Guid userId) => SessionAsync(ctx => ctx.GetUserModelDtoById(userId));
public UserModelDto? GetUserModelDtoByEmail(string email) => Session(ctx => ctx.GetUserModelDtoByEmail(email));
public Task<TUserModelDto?> GetUserModelDtoByIdAsync<TUserModelDto>(Guid userId, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase public string? GetUserJsonById(Guid userId) => Session(ctx => ctx.GetUserById(userId)?.ToJson());
=> SessionAsync(ctx => ctx.GetUserModelDtoById<TUserModelDto, User>(userId, onlyConfirmed));
public TUserModelDto? GetUserModelDtoByEmail<TUserModelDto>(string email, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase
=> Session(ctx => ctx.GetUserModelDtoByEmail<TUserModelDto, User>(email, onlyConfirmed));
public Task<TUserModelDto?> GetUserModelDtoByEmailAsync<TUserModelDto>(string email, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase
=> SessionAsync(ctx => ctx.GetUserModelDtoByEmail<TUserModelDto, User>(email, onlyConfirmed));
public string? GetUserJsonById(Guid userId, bool onlyConfirmed) => Session(ctx => ctx.GetUserById(userId, onlyConfirmed)?.ToJson());
public string GetUsersJson() => Session(ctx => ctx.Users.ToJson()); public string GetUsersJson() => Session(ctx => ctx.Users.ToJson());
public Task<bool> AddUserAsync(User user) => TransactionAsync(ctx => ctx.AddUser(user));
public Task<User?> UpdateUserAsync(User? user) => UpdateSafeAsync(user);
public Task<bool> RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId));
#region Product
public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers));
public Task<Product?> GetProductByIdAsync(Guid contextId, bool includeUsers = true) => SessionAsync(ctx => ctx.GetProductById(contextId, includeUsers));
public Task<List<ProductModelDtoName>> GetProductModelDtoNamesAsync() => SessionAsync(ctx => ctx.Products.Select(x => new ProductModelDtoName(x)).ToList()); public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers));
public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson());
public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByCompanyId(serviceProviderId, includeUsers).ToList());
public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByCompanyId(serviceProviderId, includeUsers).ToJson());
public Task<bool> AddProductAsync(Product product) => TransactionAsync(ctx => ctx.AddProduct(product));
public Task<Product?> UpdateProductAsync(Product product) => UpdateSafeAsync(product, (ctx, safeProduct) => ctx.UpdateProduct(safeProduct)); public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson());
public Task<bool> RemoveProductAsync(Product product) => RemoveProductAsync(product.Id); public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToList());
public Task<bool> RemoveProductAsync(Guid productId) => TransactionAsync(ctx => ctx.RemoveProduct(productId)); public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToJson());
#endregion Product public Task<bool> AddProduct(Product product) => TransactionAsync(ctx => ctx.AddProduct(product) && ctx.SaveChanges() > 0);
public Task<bool> UpdateProduct(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(product) && ctx.SaveChanges() > 0);
public Task<bool> RemoveProduct(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product) && ctx.SaveChanges() > 0);
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude)); public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude)); public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
public List<UserProductMapping> GetUserProductMappingsByUserId(Guid userId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingsByUserId(userId, autoInclude).ToList());
public Task<List<UserProductMapping>> GetUserProductMappingsByUserIdAsync(Guid userId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingsByUserId(userId, autoInclude).ToList());
public Task<List<UserProductMapping>> GetUserProductMappingsByProductIdAsync(Guid productId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingsByProductId(productId, autoInclude).ToList());
public List<UserProductMapping> GetAllUserProductMappings(bool autoInclude = true) => Session(ctx => ctx.UserProductMappings).ToList();
public Task<List<UserProductMapping>> GetAllUserProductMappingsAsync(bool autoInclude = true) => SessionAsync(ctx => ctx.UserProductMappings.ToList());
public List<PermissionContextMapping> GetPermissionContextsView(Guid subjectId, Guid contextId) public List<PermissionContextMapping> GetPermissionContextsView(Guid subjectId, Guid contextId)
=> Session(x => x.GetPermissionContextsView(subjectId, contextId).ToList()); => Session(x => x.GetPermissionContextsView(subjectId, contextId).ToList());
@ -281,8 +79,8 @@ namespace TIAM.Database.DataLayers.Admins
=> SessionAsync(x => x.GetPermissionContextsViewByContextId(contextId).ToList()); => SessionAsync(x => x.GetPermissionContextsViewByContextId(contextId).ToList());
#region UserProductMapping #region UserProductMapping
public Task<bool> AddUserProductMappingAsync(UserProductMapping userProductMapping)
public Task<bool> AddUserProductMappingAsync(UserProductMapping userProductMapping) => TransactionAsync(ctx => ctx.AddUserProductMapping(userProductMapping)); => TransactionAsync(ctx => ctx.AddUserProductMapping(userProductMapping) && ctx.SaveChanges() > 0);
public async Task<UserProductMapping?> AddUserProductMappingAsync(Guid userProductMappingId, Guid userId, Guid productId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null) public async Task<UserProductMapping?> AddUserProductMappingAsync(Guid userProductMappingId, Guid userId, Guid productId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
{ {
@ -291,157 +89,159 @@ namespace TIAM.Database.DataLayers.Admins
var isSucces = await TransactionAsync(ctx => var isSucces = await TransactionAsync(ctx =>
{ {
userProductMapping = ctx.AddUserProductMapping(userProductMappingId, userId, productId, permissions, userProductToCars); userProductMapping = ctx.AddUserProductMapping(userProductMappingId, userId, productId, permissions, userProductToCars);
return userProductMapping != null; return userProductMapping != null && ctx.SaveChanges() > 0;
}); });
return isSucces ? userProductMapping : null; return isSucces ? userProductMapping : null;
} }
public Task<UserProductMapping?> UpdateUserProductMappingAsync(UserProductMapping userProductMapping) => UpdateSafeAsync(userProductMapping, (ctx, safeUserProductMapping) => ctx.UpdateUserProductMapping(safeUserProductMapping)); public Task<bool> UpdateUserProductMappingAsync(UserProductMapping userProductMapping)
=> TransactionAsync(ctx => ctx.UpdateUserProductMapping(userProductMapping) && ctx.SaveChanges() > 0);
public async Task<UserProductMapping?> UpdateUserProductMappingAsync(Guid userProductMappingId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null) public async Task<UserProductMapping?> UpdateUserProductMappingAsync(Guid userProductMappingId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
{ {
UserProductMapping? userProductMapping = null; UserProductMapping? userProductMapping = null;
var isSucces = await TransactionAsync(ctx => var isSucces = await TransactionAsync(ctx =>
{ {
userProductMapping = ctx.UpdateUserProductMapping(userProductMappingId, permissions, userProductToCars); userProductMapping = ctx.UpdateUserProductMapping(userProductMappingId, permissions, userProductToCars);
return userProductMapping != null; return userProductMapping != null && ctx.SaveChanges() > 0;
}); });
return isSucces ? userProductMapping : null; return isSucces ? userProductMapping : null;
} }
public Task<bool> RemoveUserProductMappingAsync(Guid userProductMappingId) => TransactionAsync(ctx => ctx.RemoveUserProductMapping(userProductMappingId)); public Task<bool> RemoveUserProductMappingAsync(Guid userProductMappingId)
public Task<bool> RemoveUserProductMappingAsync(Guid userId, Guid productId) => TransactionAsync(ctx => ctx.RemoveUserProductMapping(userId, productId)); => TransactionAsync(ctx => ctx.RemoveUserProductMapping(userProductMappingId) && ctx.SaveChanges() > 0);
public Task<bool> RemoveUserProductMappingAsync(Guid userId, Guid productId)
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userId, productId) && ctx.SaveChanges() > 0);
#endregion UserProductMapping #endregion UserProductMapping
#region Address
public Task<Address?> GetAddressByIdAsync(Guid addressId) => SessionAsync(ctx => ctx.GetAddressById(addressId));
public Task<bool> UpdateAddressAsync(Address adress) => TransactionAsync(ctx => ctx.UpdateAddress(adress));
#endregion Address
#region Profile
public Task<Profile?> GetProfileByIdAsync(Guid profileId) => SessionAsync(ctx => ctx.GetProfileById(profileId));
public Task<bool> UpdateProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.UpdateProfile(profile));
//public Task<bool> AddProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.AddProfile(profile)); //Nem Add-olunk önmagában Profile-t! - J.
//public Task<bool> RemoveProfileAsync(Guid profileId) => TransactionAsync(ctx => ctx.RemoveProfile(profileId)); //Nem törlünk Profile-t! - J.
#endregion Profile
#region EmailMessage #region EmailMessage
public Task<EmailMessage?> GetEmailMessageByIdAsync(Guid emailMessageId) => SessionAsync(ctx => ctx.GetEmailMessageById(emailMessageId)); public Task<EmailMessage?> GetEmailMessageByIdAsync(Guid emailMessageId) => SessionAsync(ctx => ctx.GetEmailMessageById(emailMessageId));
public Task<List<EmailMessage>> GetEmailMessagesByContextIdAsync(Guid contextId) => SessionAsync(ctx => ctx.GetEmailMessagesByContextId(contextId).OrderByDescending(x => x.Created).ToList()); public Task<List<EmailMessage>> GetEmailMessagesByContextIdAsync(Guid contextId) => SessionAsync(ctx => ctx.GetEmailMessagesByContextId(contextId).ToList());
public Task<List<EmailMessage>> GetEmailMessagesBySenderIdAsync(Guid senderId) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderId(senderId).OrderByDescending(x => x.Created).ToList()); public Task<List<EmailMessage>> GetEmailMessagesBySenderIdAsync(Guid senderId) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderId(senderId).ToList());
public Task<List<EmailMessage>> GetEmailMessagesBySenderEmailAddressAsync(string emailAddress) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderEmailAddress(emailAddress).OrderByDescending(x => x.Created).ToList()); public Task<List<EmailMessage>> GetEmailMessagesBySenderEmailAddressAsync(string emailAddress) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderEmailAddress(emailAddress).ToList());
public Task<List<EmailMessage>> GetEmailMessagesByUserIdOrUpmId(Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessagesByUserIdOrUpmId<EmailMessage, EmailRecipient>(userId, userProductMappingId).OrderByDescending(x => x.Created).ToList()); public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages(userId, userProductMappingId).ToList());
public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid contextId, Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages<EmailMessage, EmailRecipient>(contextId, userId, userProductMappingId).OrderByDescending(x => x.Created).ToList()); public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid contextId, Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages(contextId, userId, userProductMappingId).ToList());
public Task<List<EmailMessage>> GetAllEmailMessagesAsync() => SessionAsync(ctx => ctx.GetAllEmailMessages<EmailMessage, EmailRecipient>().OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetEmailMessagesByUserId(Guid userId, bool onlyUnread = false)
=> SessionAsync(ctx => ctx
.GetEmailMessagesByIds<EmailMessage, EmailRecipient>(ctx.GetUserProductMappingsByUserId(userId).Select(x => x.Id).Concat([userId]))
.Where(x => !onlyUnread || !x.IsReaded)
.ToList());
/// <summary>
///
/// </summary>
/// <param name="driverId">UserProductMappingId</param>
/// <returns></returns>
public Task<List<EmailMessage>> GetTransfersMessagesByDriverIdAsync(Guid driverId)
=> SessionAsync(ctx => GetTransfersMessagesByDriverIdInnerAsync(ctx, driverId)?.OrderByDescending(x => x.Created).ToList() ?? []);
/// <summary>
///
/// </summary>
/// <param name="driverId">UserProductMappingId</param>
/// <returns></returns>
public Task<int> GetTransfersMessagesUnreadCountByDriverIdAsync(Guid driverId)
=> SessionAsync(ctx => GetTransfersMessagesByDriverIdInnerAsync(ctx, driverId)?.Count(x => !x.IsReaded) ?? 0);
/// <summary>
///
/// </summary>
/// <param name="ctx"></param>
/// <param name="driverId">UserProductMappingId</param>
/// <returns></returns>
private static IQueryable<EmailMessage>? GetTransfersMessagesByDriverIdInnerAsync(AdminDbContext ctx, Guid driverId)
{
//TODO: Az upm.UserId elvben nem kell, csak amíg nem fix a db! semmilyen gondot nem okoz... - J.
var upm = ctx.GetUserProductMappingById(driverId);
if (upm == null) return default;
//return ctx.GetEmailMessages<EmailMessage, EmailRecipient>(driverId) //TODO: jövőben elég lesz a driverId is és mehet vissza ez a sor! - J.
return ctx.GetEmailMessagesByUserIdOrUpmId<EmailMessage, EmailRecipient>(upm.UserId, driverId)
.Where(emailMessage => ctx.TransferToDrivers.Any(transferToDriver => transferToDriver.TransferId == emailMessage.ContextId && transferToDriver.UserProductMappingId == driverId));
}
public Task<bool> AddEmailMessageAsync(EmailMessage emailMessage) public Task<bool> AddEmailMessageAsync(EmailMessage emailMessage)
=> TransactionAsync(ctx => ctx.AddEmailMessage(emailMessage)); => TransactionAsync(ctx => ctx.AddEmailMessage(emailMessage) && ctx.SaveChanges() > 0);
public Task<bool> UpdateEmailMessageAsync(EmailMessage emailMessage) public Task<bool> UpdateEmailMessageAsync(EmailMessage emailMessage)
=> TransactionAsync(ctx => ctx.UpdateEmailMessage(emailMessage)); => TransactionAsync(ctx => ctx.UpdateEmailMessage(emailMessage) && ctx.SaveChanges() > 0);
public Task<bool> RemoveEmailMessageAsync(Guid emailMessageId) public Task<bool> RemoveEmailMessageAsync(Guid emailMessageId)
=> TransactionAsync(ctx => ctx.RemoveEmailMessage(emailMessageId)); => TransactionAsync(ctx => ctx.RemoveEmailMessage(emailMessageId) && ctx.SaveChanges() > 0);
#endregion EmailMessage #endregion EmailMessage
#region ServiceProviders
//15. (IServiceProviderDataService) Create service provider //15. (IServiceProviderDataService) Create service provider
public Task<bool> AddCompanyAsync(Company serviceProvider) => TransactionAsync(ctx => ctx.AddCompany<Company, Profile, Address>(serviceProvider)); public Task<bool> CreateServiceProviderAsync(TiamServiceProvider serviceProvider)
{
Context.CreateServiceProvider(serviceProvider);
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
}
public Task<List<Company>> GetCompaniesAsync() => SessionAsync(ctx => ctx.GetCompanies().ToList()); public bool CreateProductAsync(Product product)
{
Context.CreateProduct(product);
Console.WriteLine($"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}");
var _result = Context.SaveChangesAsync();
return _result.Result > 0;
}
public Task<string> GetCompaniesJsonAsync() => SessionAsync(ctx => ctx.Companies.ToJson()); public Task<List<TiamServiceProvider>> GetServiceProvidersAsync()
public string GetCompaniesJson() => Session(ctx => ctx.Companies.ToJson()); {
return Context.ServiceProviders.ToListAsync();
}
public virtual Task<Company?> GetCompanyByIdAsync(Guid id) => SessionAsync(ctx => ctx.GetCompanyById(id)); public virtual Task<TiamServiceProvider?> GetServiceProviderByIdAsync(Guid id)
public virtual Task<List<Company>> GetCompaniesByOwnerIdAsync(Guid id) => SessionAsync(ctx => ctx.GetCompaniesByOwnerId(id)); {
Console.WriteLine($"Getting serviceProvider from db {id}");
return Context.ServiceProviders.SingleOrDefaultAsync(x => x.Id == id);
}
//public Task<UserProductMapping> CreateUserProductMappingAsync(UserProductMapping userProductMapping) //public Task<UserProductMapping> CreateUserProductMappingAsync(UserProductMapping userProductMapping)
//{ //{
// Context.UserProductMappings.Add(userProductMapping); // Context.UserProductMappings.Add(userProductMapping);
// GlobalLogger.Info($"Saving userProductMapping to db {userProductMapping.Id}, {userProductMapping.ProductId}, {userProductMapping.UserId}"); // Console.WriteLine($"Saving userProductMapping to db {userProductMapping.Id}, {userProductMapping.ProductId}, {userProductMapping.UserId}");
// return Context.SaveChangesAsync().ContinueWith(x => userProductMapping); // return Context.SaveChangesAsync().ContinueWith(x => userProductMapping);
//} //}
#region ServiceProviders
//14. (IserviceProviderDataService) Update service provider //14. (IserviceProviderDataService) Update service provider
//public Task<bool> UpdateCompanyAsync(Company company) public Task<bool> UpdateServiceProviderAsync(TiamServiceProvider serviceProvider)
//{
// var result = NewUpdateCompanyAsync(company);
// return Task.FromResult(result.Result != null && !result.Result.Id.IsNullOrEmpty());
//}
public Task<Company?> UpdateCompanyAsync(Company company) => UpdateSafeAsync(company, (ctx, safeCompany) =>
{ {
ctx.Entry(safeCompany.Profile).CurrentValues.SetValues(company.Profile); var dbServiceProvider = Context.ServiceProviders.FirstOrDefault(u => u.Id == serviceProvider.Id);
return ctx.UpdateCompany(safeCompany); if (dbServiceProvider != null)
}); {
dbServiceProvider = serviceProvider;
//public Task<bool> UpdateCompanyAsync(Company company, Profile profile) Context.ServiceProviders.Update(dbServiceProvider);
// => TransactionAsync(ctx => return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
// { }
// ctx.UpdateProfile(profile); else
// ctx.SaveChanges(); {
throw new Exception("ServiceProvider not found");
// return ctx.UpdateCompany(company); }
// }); }
//13. (IserviceProviderDataService) delete service provider //13. (IserviceProviderDataService) delete service provider
public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId)); public Task<bool> DeleteServiceProviderAsync(Guid id)
{
using (var transaction = Context.Database.BeginTransaction())
{
var dbServiceProvider = Context.ServiceProviders.FirstOrDefault(u => u.Id == id);
if (dbServiceProvider != null)
{
//get products for this provider
var products = Context.Products.Where(x => x.ServiceProviderId == id).ToList();
//public Task<bool> RemoveCompanyAsync(Company company) => RemoveCompanyAsync(company.Id); /*foreach (var productItem in products)
{
//delete products
var permissionContextMappings = Context.PermissionContextMappings.Where(x => x.ContextId == productItem.Id).ToList();
//iterate through every row
foreach (var item in permissionContextMappings)
{
if (item.SubjectType == (int)PermissionContextMappingSubjectType.Group)
{
//get users in the permissiongroup
var permissionGroupUserMapping = Context.PermissionGroupUserMappings.Where(x => x.PermissionContextMappingId == item.Id).ToList();
//remove every row (users) from permissiongroup
foreach (var user in permissionGroupUserMapping)
{
Context.PermissionGroupUserMappings.Remove(user);
}
}
}
//remove permissioncontextmappings
Context.PermissionContextMappings.RemoveRange(permissionContextMappings);
}*/
Context.Products.RemoveRange(products);
Context.ServiceProviders.Remove(dbServiceProvider);
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
}
else
{
return Task.FromResult(false);
}
}
}
//17. (IServiceProviderDataService) get service provider by ownerId
public Task<List<TiamServiceProvider>> GetServiceProvidersByOwnerIdAsync()
{
throw new NotImplementedException();
}
#endregion #endregion
@ -477,7 +277,6 @@ namespace TIAM.Database.DataLayers.Admins
{ {
nextBitValue = Math.Pow(2, 0); nextBitValue = Math.Pow(2, 0);
} }
permissionsType.PermissionBit = (int)nextBitValue; permissionsType.PermissionBit = (int)nextBitValue;
Context.PermissionsTypes.Add(permissionsType); Context.PermissionsTypes.Add(permissionsType);
Context.SaveChanges(); Context.SaveChanges();
@ -490,7 +289,6 @@ namespace TIAM.Database.DataLayers.Admins
} }
} }
return Task.FromResult(result); return Task.FromResult(result);
} }
@ -521,26 +319,26 @@ namespace TIAM.Database.DataLayers.Admins
{ {
List<AssignedPermissionModel> result = new List<AssignedPermissionModel>(); List<AssignedPermissionModel> result = new List<AssignedPermissionModel>();
var userProductMappings = Context.UserProductMappings.Where(x => x.ProductId == contextId).ToList(); var UserProductMappings = Context.UserProductMappings.Where(x => x.ProductId == contextId).ToListAsync();
//if (userProductMappings.Result != null) if (UserProductMappings.Result != null)
{ {
foreach (var item in userProductMappings) foreach (var item in UserProductMappings.Result)
{ {
var mappingRows = Context.PermissionContextMappings.Where(x => x.SubjectId == item.Id).ToList(); var mappingRow = Context.PermissionContextMappings.Where(x => x.SubjectId == item.Id).ToListAsync();
if (mappingRows.Count == 0) if (mappingRow.Result == null)
{ {
//user has no permission but is assigned... must be banned //user has no permission but is assigned... must be banned
} }
else if (mappingRows.Count > 1) else if (mappingRow.Result.Count > 1)
{ {
//user has been assigned more than onece to same context //user has been assigned more than onece to same context
} }
else else
{ {
foreach (var mapping in mappingRows) foreach (var mapping in mappingRow.Result)
{ {
result.Add(new AssignedPermissionModel(item.ProductId, item.Id, mapping.SubjectType, item.UserId.ToString(), mapping.Permissions)); result.Add(new AssignedPermissionModel(item.ProductId, item.Id, mapping.SubjectType, item.UserId.ToString(), mapping.Permissions));
} }
@ -549,26 +347,26 @@ namespace TIAM.Database.DataLayers.Admins
} }
} }
var assingedGroups = Context.PermissionGroups.Where(x => x.OwnerId == contextId).ToList(); var AssingedGroups = Context.PermissionGroups.Where(x => x.OwnerId == contextId).ToListAsync();
//if (assingedGroups.Result != null) if (AssingedGroups.Result != null)
{ {
foreach (var group in assingedGroups) foreach (var group in AssingedGroups.Result)
{ {
var mappingRows = Context.PermissionContextMappings.Where(x => x.SubjectId == group.Id).ToList(); var mappingRow = Context.PermissionContextMappings.Where(x => x.SubjectId == group.Id).ToListAsync();
if (mappingRows.Count == 0) if (mappingRow.Result == null)
{ {
//group has no permission but is assigned... //group has no permission but is assigned...
} }
else if (mappingRows.Count > 1) else if (mappingRow.Result.Count > 1)
{ {
//group has been assigned more than onece to same context //group has been assigned more than onece to same context
} }
else else
{ {
foreach (var mapping in mappingRows) foreach (var mapping in mappingRow.Result)
{ {
result.Add(new AssignedPermissionModel(group.OwnerId, group.Id, mapping.SubjectType, group.GroupName, mapping.Permissions)); result.Add(new AssignedPermissionModel(group.OwnerId, group.Id, mapping.SubjectType, group.GroupName, mapping.Permissions));
} }
@ -578,9 +376,8 @@ namespace TIAM.Database.DataLayers.Admins
} }
foreach (var row in result) foreach (var row in result)
{ {
GlobalLogger.Info($@"GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId: {row.ContextId}, {row.SubjectId}, {row.SubjectType}, {row.Name}, {row.PermissionsValue}"); Console.WriteLine($"GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId: {row.ContextId}, {row.SubjectId}, {row.SubjectType}, {row.Name}, {row.PermissionsValue}");
} }
return Task.FromResult(result); return Task.FromResult(result);
} }
@ -616,12 +413,11 @@ namespace TIAM.Database.DataLayers.Admins
transaction.Commit(); transaction.Commit();
result = true; result = true;
} }
return Task.FromResult(result); return Task.FromResult(result);
} }
//8. (IPermissionService) create permission group //8. (IPermissionService) create permission group
public Task<bool> CreatePermissionGroupAsync(PermissionGroup permissionGroup, Company serviceProvider) public Task<bool> CreatePermissionGroupAsync(PermissionGroup permissionGroup, TiamServiceProvider serviceProvider)
{ {
bool result = false; bool result = false;
using (var transaction = Context.Database.BeginTransaction()) using (var transaction = Context.Database.BeginTransaction())
@ -651,7 +447,6 @@ namespace TIAM.Database.DataLayers.Admins
result = false; result = false;
} }
} }
return Task.FromResult(result); return Task.FromResult(result);
} }
@ -682,6 +477,17 @@ namespace TIAM.Database.DataLayers.Admins
#region Products #region Products
//* 21. (IServiceProviderDataService) delete product
public Task<bool> DeleteProductByIdAsync(Guid productId)
{
return TransactionAsync(ctx =>
{
ctx.DeleteProductById(productId);
return true;
});
}
//4. (IPermissionService) AssignPermissionToUserForContextAsync //4. (IPermissionService) AssignPermissionToUserForContextAsync
public Task<bool> AssignPermissionToUserForContextAsync(UserProductMapping userProductMapping, PermissionsType permission) public Task<bool> AssignPermissionToUserForContextAsync(UserProductMapping userProductMapping, PermissionsType permission)
{ {
@ -710,8 +516,15 @@ namespace TIAM.Database.DataLayers.Admins
#region UserProductMappings #region UserProductMappings
//23. (IServiceProviderDataService) Get Assigned Users By ProductId
public Task<List<UserProductMapping>> GetUserProductMappingsByProductIdAsync(Guid productId)
{
return Context.UserProductMappings.Where(x => x.ProductId == productId).ToListAsync();
}
//24 . (IServiceProviderDataService) Remove Assigned Users By Product Id //24 . (IServiceProviderDataService) Remove Assigned Users By Product Id
public Task RemoveUserProductMappingsByProductId(Guid productId) public Task RemoveUserProductMappingsByContextId(Guid productId)
{ {
using (var transaction = Context.Database.BeginTransaction()) using (var transaction = Context.Database.BeginTransaction())
{ {
@ -751,11 +564,5 @@ namespace TIAM.Database.DataLayers.Admins
#endregion #endregion
#region Logs
public Task<List<AcLogItem>> GetLogItemsAsync(int takeCount, DateTime utcFromDate, DateTime utcToDate) => SessionAsync(ctx => ctx.LogItems.Where(x => x.TimeStampUtc.Date >= utcFromDate.Date && x.TimeStampUtc.Date <= utcToDate.Date).Take(takeCount).ToList());
public Task<List<AcLogItem>> GetLogItemsByFilterAsync(CriteriaOperator criteriaOperator, int takeCount, DateTime utcFromDate, DateTime utcToDate) => SessionAsync(ctx => (ctx.LogItems.Where(x => x.TimeStampUtc.Date >= utcFromDate.Date && x.TimeStampUtc.Date <= utcToDate.Date).AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator).Take(takeCount) as IQueryable<AcLogItem>)!.ToList());
#endregion
} }
} }

View File

@ -1,5 +1,13 @@
using AyCode.Core.Extensions; using AyCode.Interfaces.Entities;
using AyCode.Utils.Extensions; using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TIAM.Core.Interfaces;
using TIAM.Database.DbContexts.Admins;
using TIAM.Database.DbContexts.ServiceProviders;
using TIAM.Database.DbSets.Permissions; using TIAM.Database.DbSets.Permissions;
using TIAM.Database.DbSets.Products; using TIAM.Database.DbSets.Products;
using TIAM.Database.DbSets.Users; using TIAM.Database.DbSets.Users;
@ -8,9 +16,9 @@ using TIAM.Entities.Products;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
namespace TIAM.Database.DbContexts.Admins namespace TIAM.Database.DataLayers.Admins
{ {
public static class AdminDbContextExtension public static class AdminDalDbContextExtension
{ {
public static IQueryable<UserProductMapping> GetUserProductMappingsByPermissionGroupId(this IAdminDbContext ctx, Guid permissionGroupId) public static IQueryable<UserProductMapping> GetUserProductMappingsByPermissionGroupId(this IAdminDbContext ctx, Guid permissionGroupId)
{ {
@ -93,39 +101,48 @@ namespace TIAM.Database.DbContexts.Admins
return true; return true;
} }
//public static bool CreateProduct(this IAdminDbContext ctx, Product myproduct) public static bool CreateProduct(this IAdminDbContext ctx, Product myproduct)
//{ {
// if (myproduct == null) return false; if (myproduct == null) return false;
//Automatically add assigneduser for owner
TiamServiceProvider? productOwner = ctx.ServiceProviders.FirstOrDefault(x => x.Id == myproduct.ServiceProviderId);
if (productOwner == null) return false;
var userProductMapping = new UserProductMapping(myproduct.Id, productOwner.OwnerId);
ctx.CreateAssignedUser(userProductMapping);
ctx.AddProduct(myproduct);
// //Automatically add assigneduser for owner return true;
// Company? company = ctx.Companies.FirstOrDefault(x => x.Id == myproduct.ServiceProviderId); }
// if (company == null || company.OwnerId.IsNullOrEmpty()) return false;
// var userProductMapping = new UserProductMapping(myproduct.Id, company.OwnerId.Value); public static bool CreateAssignedUser(this IAdminDbContext ctx, UserProductMapping userProductMapping)
{
if (userProductMapping == null) return false;
// ctx.CreateAssignedUser(userProductMapping); ctx.UserProductMappings.Add(userProductMapping);
// ctx.AddProduct(myproduct);
// return true; return true;
//} }
//public static bool CreateAssignedUser(this IAdminDbContext ctx, UserProductMapping userProductMapping) public static TiamServiceProvider CreateServiceProvider(this IAdminDbContext ctx, TiamServiceProvider serviceProvider)
//{ {
// if (userProductMapping == null) return false; if (serviceProvider == null) return null;
// ctx.UserProductMappings.Add(userProductMapping); ctx.ServiceProviders.Add(serviceProvider);
var userProductMapping = new UserProductMapping(serviceProvider.Id, serviceProvider.OwnerId);
ctx.CreateAssignedUser(userProductMapping);
return serviceProvider;
}
// return true; public static TiamServiceProvider UpdateServiceProvider(this IAdminDbContext ctx, TiamServiceProvider serviceProvider)
//} {
if (serviceProvider == null) return null;
//public static Company CreateServiceProvider(this IAdminDbContext ctx, Company serviceProvider) var existingServiceProvider = ctx.ServiceProviders.FirstOrDefault(u => u.Id == serviceProvider.Id);
//{ if (existingServiceProvider == null) return null;
// if (serviceProvider == null || serviceProvider.OwnerId.IsNullOrEmpty()) return null;
// ctx.Companies.Add(serviceProvider); existingServiceProvider.Name = serviceProvider.Name;
// var userProductMapping = new UserProductMapping(serviceProvider.Id, serviceProvider.OwnerId.Value); existingServiceProvider.OwnerId = serviceProvider.OwnerId;
// ctx.CreateAssignedUser(userProductMapping); return existingServiceProvider;
// return serviceProvider; }
//}
} }
} }

View File

@ -1,4 +1,4 @@
using AyCode.Core.Server.Loggers; using AyCode.Core.Logger;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbContexts.Auctions; using TIAM.Database.DbContexts.Auctions;
using TIAM.Entities.Auctions; using TIAM.Entities.Auctions;
@ -19,14 +19,14 @@ namespace TIAM.Database.DataLayers.Auctions
public Task<List<AuctionBid>> GetBidsByEmail(string email) public Task<List<AuctionBid>> GetBidsByEmail(string email)
{ {
GlobalLogger.Info($"Getting bid from db {email}"); Logger.Info($"Getting bid from db {email}");
var emailLower = email.ToLower(); var emailLower = email.ToLower();
return Context.AuctionBids.Where(x => x.Email.ToLower() == emailLower).ToListAsync(); return Context.AuctionBids.Where(x => x.Email.ToLower() == emailLower).ToListAsync();
} }
public AuctionBid? GetBidById(Guid id) public AuctionBid? GetBidById(Guid id)
{ {
GlobalLogger.Info($"Getting bid from db {id}"); Logger.Info($"Getting bid from db {id}");
return Context.AuctionBids.FirstOrDefault(x => x.Id == id); return Context.AuctionBids.FirstOrDefault(x => x.Id == id);
} }
@ -36,7 +36,7 @@ namespace TIAM.Database.DataLayers.Auctions
auctionBid.Created = DateTime.UtcNow; auctionBid.Created = DateTime.UtcNow;
auctionBid.Modified = DateTime.UtcNow; auctionBid.Modified = DateTime.UtcNow;
Context.AuctionBids.Add(auctionBid); Context.AuctionBids.Add(auctionBid);
GlobalLogger.Info($"Saving user to db {auctionBid.Id}, {auctionBid.Email}, {auctionBid.PhoneNumber}"); Logger.Info($"Saving user to db {auctionBid.Id}, {auctionBid.Email}, {auctionBid.PhoneNumber}");
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0); return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
} }

View File

@ -1,9 +1,16 @@
using AyCode.Database.DataLayers; using AyCode.Database;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Database.DataLayers;
using TIAM.Database.DbContexts; using TIAM.Database.DbContexts;
namespace TIAM.Database.DataLayers; namespace TIAM.Database.DataLayers;
public class DalBase<TDbContext> : AcDalBase<TDbContext>, IDalBase<TDbContext> where TDbContext : DbContextBase public class DalBase<TDbContext> : AcDalBase<TDbContext> where TDbContext : DbContextBase
{ {
//public DalBase() : base(new TransferDestinationDbContext("DeveloperDbConnection")) //public DalBase() : base(new TransferDestinationDbContext("DeveloperDbConnection"))
//{ //{

View File

@ -1,10 +0,0 @@
using AyCode.Database.DataLayers;
using TIAM.Database.DbContexts;
namespace TIAM.Database.DataLayers;
public interface IDalBase : IAcDalBase
{ }
public interface IDalBase<TDbContext> : IAcDalBase<TDbContext>, IAcDalBase where TDbContext : DbContextBase
{ }

View File

@ -1,4 +1,26 @@
namespace TIAM.Database.DataLayers.ServiceProviders using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Models.Enums;
using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Permissions;
using TIAM.Entities.Products;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
using TIAM.Database.DbContexts.ServiceProviders;
using TIAM.Database.DbSets.Permissions;
using TIAM.Database.DbSets.Users;
using AyCode.Database.DataLayers;
using AyCode.Database.DbSets.Users;
using TIAM.Database.DbSets.Products;
using TIAM.Entities.TransferDestinations;
using TIAM.Models.Dtos.Users;
using Newtonsoft.Json;
namespace TIAM.Database.DataLayers.ServiceProviders
{ {
//public class ServiceProviderDal : DalBase<ServiceProviderDbContext> //public class ServiceProviderDal : DalBase<ServiceProviderDbContext>
//{ //{
@ -14,7 +36,7 @@
//// #region ServiceProviders //// #region ServiceProviders
//// //14. (IserviceProviderDataService) Update service provider //// //14. (IserviceProviderDataService) Update service provider
//// public Task<bool> UpdateServiceProviderAsync(Company serviceProvider) //// public Task<bool> UpdateServiceProviderAsync(TiamServiceProvider serviceProvider)
//// { //// {
//// var dbServiceProvider = Context.ServiceProviders.FirstOrDefault(u => u.Id == serviceProvider.Id); //// var dbServiceProvider = Context.ServiceProviders.FirstOrDefault(u => u.Id == serviceProvider.Id);
//// if (dbServiceProvider != null) //// if (dbServiceProvider != null)
@ -74,7 +96,7 @@
//// } //// }
//// //17. (IServiceProviderDataService) get service provider by ownerId //// //17. (IServiceProviderDataService) get service provider by ownerId
//// public Task<List<Company>> GetServiceProvidersByOwnerIdAsync() //// public Task<List<TiamServiceProvider>> GetServiceProvidersByOwnerIdAsync()
//// { //// {
//// throw new NotImplementedException(); //// throw new NotImplementedException();
@ -213,7 +235,7 @@
//// } //// }
//// foreach (var row in result) //// foreach (var row in result)
//// { //// {
//// GlobalLogger.Info($"GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId: {row.ContextId}, {row.SubjectId}, {row.SubjectType}, {row.Name}, {row.PermissionsValue}"); //// Console.WriteLine($"GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId: {row.ContextId}, {row.SubjectId}, {row.SubjectType}, {row.Name}, {row.PermissionsValue}");
//// } //// }
//// return Task.FromResult(result); //// return Task.FromResult(result);
//// } //// }
@ -254,7 +276,7 @@
//// } //// }
//// //8. (IPermissionService) create permission group //// //8. (IPermissionService) create permission group
//// public Task<bool> CreatePermissionGroupAsync(PermissionGroup permissionGroup, Company serviceProvider) //// public Task<bool> CreatePermissionGroupAsync(PermissionGroup permissionGroup, TiamServiceProvider serviceProvider)
//// { //// {
//// bool result = false; //// bool result = false;
//// using (var transaction = Context.Database.BeginTransaction()) //// using (var transaction = Context.Database.BeginTransaction())
@ -319,7 +341,7 @@
//// { //// {
//// var prod = Context.UpdateProduct(product); //// var prod = Context.UpdateProduct(product);
//// GlobalLogger.Info($"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}"); //// Console.WriteLine($"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}");
//// Context.SaveChanges(); //// Context.SaveChanges();
//// return prod; //// return prod;
//// } //// }

View File

@ -1,4 +1,19 @@
 using AyCode.Database.DataLayers.Users;
using AyCode.Interfaces.Entities;
using AyCode.Models.Enums;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Newtonsoft.Json;
using TIAM.Database.DbContexts;
using TIAM.Database.DbContexts.ServiceProviders;
using TIAM.Database.DbSets.Permissions;
using TIAM.Database.DbSets.Products;
using TIAM.Database.DbSets.Users;
using TIAM.Entities.Permissions;
using TIAM.Entities.Products;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
//namespace TIAM.Database.DataLayers.ServiceProviders; //namespace TIAM.Database.DataLayers.ServiceProviders;

View File

@ -1,7 +1,15 @@
using AyCode.Core.Extensions; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Database;
using AyCode.Utils.Extensions;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Identity.Client;
using TIAM.Database.DbContexts.Transfers; using TIAM.Database.DbContexts.Transfers;
using TIAM.Entities.Transfers; using TIAM.Entities.TransferDestinations;
using TIAM.Entities.Users;
namespace TIAM.Database.DataLayers.TransferDestinations; namespace TIAM.Database.DataLayers.TransferDestinations;

View File

@ -1,66 +1,99 @@
using AyCode.Database.DataLayers.Users; using System;
using AyCode.Database.DbSets.Messages; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Database.DataLayers;
using AyCode.Database.DataLayers.Users;
using AyCode.Database.DbSets.Users; using AyCode.Database.DbSets.Users;
using AyCode.Entities.Users;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbContexts.Users; using TIAM.Database.DbContexts.Users;
using TIAM.Database.DbSets.Users;
using TIAM.Entities.Addresses; using TIAM.Entities.Addresses;
using TIAM.Entities.Emails;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using EmailMessage = TIAM.Entities.Emails.EmailMessage;
namespace TIAM.Database.DataLayers.Users namespace TIAM.Database.DataLayers.Users
{ {
public class UserDal : AcUserDalBase<UserDbContext, User, Profile, UserToken, Company, UserToCompany, Address, EmailMessage>, IDalBase<UserDbContext> public class UserDal : AcUserDalBase<UserDbContext, User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider, Address>
{ {
public UserDal() : base() public UserDal() : base()
{ {
} }
public UserDal(UserDbContext context) public UserDal(UserDbContext _object)
{ {
} }
//public Task<SiteViewModel> GetSiteViewModelByUserId(Guid userId) => SessionAsync(ctx => public UserModelDto? GetUserModelDtoById(Guid userId) => Session(x => x.GetUserModelDtoById(userId));
public Task<UserModelDto?> GetUserModelDtoByIdAsync(Guid userId) => SessionAsync(x => x.GetUserModelDtoById(userId));
public Task<UserModelDto?> GetUserModelDtoByEmailAsync(string email) => SessionAsync(x => x.GetUserModelDtoByEmail(email));
public Task<List<UserModelDto>> GetAllUsersModelDtoAsync() => SessionAsync(x => x.GetAllUsersModelDto().ToList());
public Task<User?> GetUserByPhoneNumberAsync(string phoneNumber)
{
Console.WriteLine($"Getting user from db {phoneNumber}");
var phoneNumberLower = phoneNumber.ToLower();
return Context.Users.SingleOrDefaultAsync(x=>x.PhoneNumber.Equals(phoneNumberLower, StringComparison.CurrentCultureIgnoreCase));
}
public Task<User?> GetUserByEmailOrPhoneNumberAsync(string emailOrPhoneNumber)
{
Console.WriteLine($"Getting user from db {emailOrPhoneNumber}");
var emailOrPhoneNumberLower = emailOrPhoneNumber.ToLower();
return Context.Users.SingleOrDefaultAsync(x=>x.EmailAddress.Equals(emailOrPhoneNumberLower, StringComparison.CurrentCultureIgnoreCase) || x.PhoneNumber.Equals(emailOrPhoneNumberLower, StringComparison.CurrentCultureIgnoreCase));
}
////get user by Id
//public Task<User?> GetUserByIdAsync(Guid id)
//{ //{
// ctx.GetEmailMessagesByUserIdOrUpmId<EmailMessage, EmailRecipient>(userId, // Console.WriteLine($"Getting user from db {id}");
//})); // return Context.Users.SingleOrDefaultAsync(x=>x.Id == id);
//}
public Task<List<UserModelDtoEmail>> GetUserModelDtoEmailsAsync() => SessionAsync(ctx => ctx.Users.Select(x => new UserModelDtoEmail(x)).ToList());
public override Task<User?> UpdateUserAsync(User user) => base.UpdateSafeAsync(user);
public async Task<UserModelDtoDetail?> UpdateUserModelDtoDetailAsync(UserModelDtoDetail userModelDtoDetail)
{
var user = GetUserById(userModelDtoDetail.UserDto.Id, false);
if (user == null) return null;
userModelDtoDetail.CopyUserDtoValuesToUser(user);
return await UpdateUserAsync(user) == null ? null : await GetUserModelDtoByIdAsync<UserModelDtoDetail>(userModelDtoDetail.Id, false);
}
public async Task<UserModelDtoDetail?> AddUserModelDtoDetailAsync(UserModelDtoDetail userModelDtoDetail)
{
var user = new User();
userModelDtoDetail.CopyUserDtoValuesToUser(user);
return await AddUserAsync(user) ? await GetUserModelDtoByIdAsync<UserModelDtoDetail>(userModelDtoDetail.Id, false) : null;
}
public async Task<bool> CreateUserAsync(User user) public async Task<bool> CreateUserAsync(User user)
{ {
Context.Users.Add(user); Context.Users.Add(user);
Profile profile = new Profile(); Console.WriteLine($"Saving user to db {user.Id}, {user.EmailAddress}, {user.PhoneNumber}, {user.Password}");
profile.Id = Guid.NewGuid();
var parts = user.EmailAddress.Split('@');
profile.Name = parts[0];
Context.Profiles.Add(profile);
Console.WriteLine($@"Saving user to db {user.Id}, {user.EmailAddress}, {user.PhoneNumber}, {user.Password}");
return await Context.SaveChangesAsync() > 0; return await Context.SaveChangesAsync() > 0;
} }
public async Task<bool> UpdateJwtRefreshTokenAsync(string email, string refreshToken)
{
Console.WriteLine("UserDal Update refresh token");
var existingUser = Context.Users.FirstOrDefault(u => u.EmailAddress == email);
if (existingUser != null)
{
//user.Modified = DateTime.UtcNow; //ezt nem kell megadni, a háttérben ezt magától megcsinálja a DbContextBase - J.
existingUser.RefreshToken = refreshToken;
Context.Users.Update(existingUser);
return await Context.SaveChangesAsync() > 0;
}
else
{
throw new Exception("User not found");
}
}
public async Task<bool> UpdateUserAsync(User user)
{
var existingUser = await Context.Users.CountAsync(u => u.EmailAddress == user.EmailAddress);
if (existingUser == 1)
{
//user.Modified = DateTime.UtcNow; //ezt nem kell megadni, a háttérben ezt magától megcsinálja a DbContextBase - J.
Context.Users.Update(user);
return await Context.SaveChangesAsync() > 0;
}
else
{
throw new Exception("User not found");
}
}
} }
} }

View File

@ -1,6 +1,10 @@
using AyCode.Entities.Server.LogItems; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Database.DbContexts;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Database.ModelBuilders.Companies;
using TIAM.Database.ModelBuilders.Emails; using TIAM.Database.ModelBuilders.Emails;
using TIAM.Database.ModelBuilders.Products; using TIAM.Database.ModelBuilders.Products;
using TIAM.Database.ModelBuilders.Transfers; using TIAM.Database.ModelBuilders.Transfers;
@ -12,6 +16,7 @@ using TIAM.Entities.Permissions;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.TransferDestinations;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
using TIAM.Entities.Users; using TIAM.Entities.Users;
@ -19,20 +24,11 @@ namespace TIAM.Database.DbContexts.Admins
{ {
public class AdminDbContext : DbContextBase, IAdminDbContext public class AdminDbContext : DbContextBase, IAdminDbContext
{ {
public DbSet<AcLogItem> LogItems { get; set; }
public DbSet<User> Users { get; set; } public DbSet<User> Users { get; set; }
public DbSet<Profile> Profiles { get; set; }
public DbSet<Company> Companies { get; set; }
public DbSet<UserToCompany> UserToCompanies { get; set; }
public DbSet<UserToken> UserTokens { get; set; }
public DbSet<TransferDestination> TransferDestinations { get; set; } public DbSet<TransferDestination> TransferDestinations { get; set; }
public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; }
public DbSet<Transfer> Transfers { get; set; } public DbSet<Transfer> Transfers { get; set; }
public DbSet<TransferToDriver> TransferToDrivers { get; set; }
public DbSet<Car> Cars { get; set; }
//public DbSet<Company> ServiceProviders { get; set; } public DbSet<TiamServiceProvider> ServiceProviders { get; set; }
public DbSet<Product> Products { get; set; } public DbSet<Product> Products { get; set; }
public DbSet<UserProductMapping> UserProductMappings { get; set; } public DbSet<UserProductMapping> UserProductMappings { get; set; }
public DbSet<PermissionGroup> PermissionGroups { get; set; } public DbSet<PermissionGroup> PermissionGroups { get; set; }
@ -73,19 +69,9 @@ namespace TIAM.Database.DbContexts.Admins
new TransferEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<Transfer>()); new TransferEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<Transfer>());
modelBuilder.Entity<TransferDestination>().Navigation(e => e.Address).AutoInclude(true); modelBuilder.Entity<TransferDestination>().Navigation(e => e.Address).AutoInclude(true);
modelBuilder.Entity<TransferToDriver>().Navigation(e => e.Car).AutoInclude(true);
modelBuilder.Entity<TransferDestinationToProduct>().HasOne(e => e.TransferDestination);
modelBuilder.Entity<TransferDestinationToProduct>().Navigation(e => e.TransferDestination).AutoInclude(true);
new EmailMessageEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<EmailMessage>()); new EmailMessageEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<EmailMessage>());
new CompanyEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<Company>());
modelBuilder.Entity<Company>().Navigation(e => e.Profile).AutoInclude(true);
modelBuilder.Entity<Company>().HasOne(x => x.Profile).WithOne().OnDelete(DeleteBehavior.Cascade);
//modelBuilder.Entity<UserProductToCar>().Ignore(x => x.Id); //modelBuilder.Entity<UserProductToCar>().Ignore(x => x.Id);
//modelBuilder.Entity<Car>().Ignore(x => x.Id); //modelBuilder.Entity<Car>().Ignore(x => x.Id);
////modelBuilder.Entity<UserProductToCars>().Ignore(x => x.Cars); ////modelBuilder.Entity<UserProductToCars>().Ignore(x => x.Cars);
@ -94,33 +80,32 @@ namespace TIAM.Database.DbContexts.Admins
//modelBuilder.Entity<Car>().HasNoKey(); //modelBuilder.Entity<Car>().HasNoKey();
//modelBuilder.Entity<UserProductToCar>().HasNoKey(); //modelBuilder.Entity<UserProductToCar>().HasNoKey();
//JSONMODEL - J. modelBuilder.Entity<UserProductMapping>().OwnsOne(
//modelBuilder.Entity<UserProductMapping>().OwnsOne( userToProduct => userToProduct.JsonDetailModel, builderUserProductJsonDetail =>
// userToProduct => userToProduct.JsonDetailModel, builderUserProductJsonDetail => {
// { builderUserProductJsonDetail.ToJson();
// builderUserProductJsonDetail.ToJson(); //builderUserProductJsonDetail.Property(nameof(UserProductMapping.JsonDetailModel)).HasColumnName("JsonDetailModel");
// //builderUserProductJsonDetail.Property(nameof(UserProductMapping.JsonDetailModel)).HasColumnName("JsonDetailModel");
// builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars, builderUserProductToCar => builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars, builderUserProductToCar =>
// { {
// //builderUserProductToCar.ToJson(); //builderUserProductToCar.ToJson();
// //builderUserProductToCar.Ignore(x => x.UserProductToCarId); //builderUserProductToCar.Ignore(x => x.UserProductToCarId);
// //builderUserProductToCar.Ignore(x => x.Created); //builderUserProductToCar.Ignore(x => x.Created);
// //builderUserProductToCar.Ignore(x => x.Modified); //builderUserProductToCar.Ignore(x => x.Modified);
// builderUserProductToCar.OwnsOne(userProductToCar => userProductToCar.Car, builderCar => builderUserProductToCar.OwnsOne(userProductToCar => userProductToCar.Car, builderCar =>
// { {
// //builderCar.ToJson(); //builderCar.ToJson();
// //builderCar.Ignore(x => x.Id); //builderCar.Ignore(x => x.Id);
// //builderCar.Ignore(x => x.Created); //builderCar.Ignore(x => x.Created);
// //builderCar.Ignore(x => x.Modified); //builderCar.Ignore(x => x.Modified);
// }); });
// }); });
// //builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars2); //builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars2);
// }); });
//modelBuilder.Entity<UserProductToCar>().OwnsOne( //modelBuilder.Entity<UserProductToCar>().OwnsOne(
// userToProduct => userToProduct.Car, ownedNavigationBuilder => // userToProduct => userToProduct.Car, ownedNavigationBuilder =>

View File

@ -1,22 +1,14 @@
using AyCode.Database.DbContexts.Users; using TIAM.Database.DbSets.Addresses;
using TIAM.Database.DbSets.Drivers;
using TIAM.Database.DbSets.Emails; using TIAM.Database.DbSets.Emails;
using TIAM.Database.DbSets.Permissions; using TIAM.Database.DbSets.Permissions;
using TIAM.Database.DbSets.Products; using TIAM.Database.DbSets.Products;
using TIAM.Database.DbSets.ServiceProvider; using TIAM.Database.DbSets.ServiceProvider;
using TIAM.Database.DbSets.Transfers; using TIAM.Database.DbSets.Transfers;
using TIAM.Database.DbSets.Users; using TIAM.Database.DbSets.Users;
using TIAM.Entities.Addresses;
using TIAM.Entities.Emails;
using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
namespace TIAM.Database.DbContexts.Admins; namespace TIAM.Database.DbContexts.Admins;
public interface IAdminDbContext : public interface IAdminDbContext :
ICompanyDbSet, IProductDbSet, IDriverDbSet, IServiceProviderDbSet, IProductDbSet, IUserProductMappingDbSet, IUserDbSet, IPermissionsDbSetContext, IAddressDbSet, ITransferDestinationDbSet, ITransferDbSet, IEmailMessageDbSet
IAcUserDbContextBase<User, Profile, UserToken, Company, UserToCompany, Address, EmailMessage>,
IPermissionsDbSetContext, ITransferDestinationDbSet, ITransferDbSet, IEmailMessageDbSet
{ {
} }

View File

@ -1,5 +1,12 @@
using Microsoft.EntityFrameworkCore; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Database.DbContexts;
using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Auctions; using TIAM.Entities.Auctions;
using TIAM.Entities.TransferDestinations;
namespace TIAM.Database.DbContexts.Auctions namespace TIAM.Database.DbContexts.Auctions
{ {

View File

@ -1,4 +1,10 @@
using AyCode.Database.DbContexts; using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using AyCode.Database.DbContexts;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -26,11 +32,9 @@ namespace TIAM.Database.DbContexts
optionsBuilder.UseLazyLoadingProxies(true); optionsBuilder.UseLazyLoadingProxies(true);
optionsBuilder.EnableDetailedErrors(true); optionsBuilder.EnableDetailedErrors(true);
//optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTrackingWithIdentityResolution);
//optionsBuilder.UseSqlServer(Configuration.GetConnectionString("DeveloperDbConnection")); //optionsBuilder.UseSqlServer(Configuration.GetConnectionString("DeveloperDbConnection"));
//var connString = "Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Trusted_Connection=false;Encrypt=false;TrustServerCertificate=True;Connect Timeout=200;User ID=Anata_Development_Team;Password=v6f_?xNfg9N1;MultipleActiveResultSets=true"; var connString = "Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Trusted_Connection=false;Encrypt=false;TrustServerCertificate=True;Connect Timeout=200;User ID=Anata_Development_Team;Password=v6f_?xNfg9N1;MultipleActiveResultSets=true";
//optionsBuilder.UseSqlServer(connString); optionsBuilder.UseSqlServer(connString);
} }
} }
} }

View File

@ -1,4 +1,5 @@
using TIAM.Database.DbSets.Addresses; using AyCode.Database.DbSets.Users;
using TIAM.Database.DbSets.Addresses;
using TIAM.Database.DbSets.Permissions; using TIAM.Database.DbSets.Permissions;
using TIAM.Database.DbSets.Products; using TIAM.Database.DbSets.Products;
using TIAM.Database.DbSets.ServiceProvider; using TIAM.Database.DbSets.ServiceProvider;
@ -7,6 +8,6 @@ using TIAM.Database.DbSets.Users;
namespace TIAM.Database.DbContexts.ServiceProviders; namespace TIAM.Database.DbContexts.ServiceProviders;
public interface IServiceProviderDbContext : ICompanyDbSet, IProductDbSet, IUserProductMappingDbSet, IUserDbSet, IPermissionsDbSetContext, IAddressDbSet, ITransferDestinationDbSet public interface IServiceProviderDbContext : IServiceProviderDbSet, IProductDbSet, IUserProductMappingDbSet, IUserDbSet, IPermissionsDbSetContext, IAddressDbSet, ITransferDestinationDbSet
{ {
} }

View File

@ -1,11 +1,21 @@
using Microsoft.EntityFrameworkCore; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Database.DbContexts;
using AyCode.Database.DbContexts.Users;
using AyCode.Entities.Users;
using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbContexts.Users;
using TIAM.Database.DbSets.Users;
using TIAM.Database.ModelBuilders.Products;
using TIAM.Database.ModelBuilders.Users; using TIAM.Database.ModelBuilders.Users;
using TIAM.Entities.Addresses; using TIAM.Entities.Addresses;
using TIAM.Entities.Permissions; using TIAM.Entities.Permissions;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Transfers; using TIAM.Entities.TransferDestinations;
using TIAM.Entities.Users; using TIAM.Entities.Users;
namespace TIAM.Database.DbContexts.ServiceProviders namespace TIAM.Database.DbContexts.ServiceProviders
@ -14,17 +24,12 @@ namespace TIAM.Database.DbContexts.ServiceProviders
{ {
public DbSet<Address> Addresses { get; set; } public DbSet<Address> Addresses { get; set; }
public DbSet<TransferDestination> TransferDestinations { get; set; } public DbSet<TransferDestination> TransferDestinations { get; set; }
public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; }
public DbSet<Company> Companies { get; set; }
public DbSet<UserToCompany> UserToCompanies { get; set; }
public DbSet<Profile> Profiles { get; set; }
public DbSet<User> Users { get; set; } public DbSet<User> Users { get; set; }
public DbSet<UserProductMapping> UserProductMappings { get; set; } public DbSet<UserProductMapping> UserProductMappings { get; set; }
public DbSet<Product> Products { get; set; } public DbSet<Product> Products { get; set; }
public DbSet<Company> ServiceProviders { get; set; } public DbSet<TiamServiceProvider> ServiceProviders { get; set; }
public DbSet<PermissionsType> PermissionsTypes { get; set; } public DbSet<PermissionsType> PermissionsTypes { get; set; }
@ -62,10 +67,8 @@ namespace TIAM.Database.DbContexts.ServiceProviders
new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>()); new UserEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<User>());
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>()); //new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
//modelBuilder.Entity<TransferDestinationToProduct>().HasOne(e => e.TransferDestination); new ProductEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<Product>());
//modelBuilder.Entity<TransferDestinationToProduct>().Navigation(e => e.TransferDestination).AutoInclude(true); modelBuilder.Entity<TransferDestination>().Navigation(e => e.Address).AutoInclude(true);
} }
public DbSet<TransferToDriver> TransferToDrivers { get; set; }
} }
} }

View File

@ -1,5 +1,10 @@
using Microsoft.EntityFrameworkCore; using System;
using TIAM.Entities.Transfers; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using TIAM.Entities.TransferDestinations;
namespace TIAM.Database.DbContexts.Transfers namespace TIAM.Database.DbContexts.Transfers
{ {

View File

@ -1,10 +1,10 @@
using AyCode.Database.DbContexts.Users; using AyCode.Database.DbContexts.Users;
using AyCode.Entities.Users;
using TIAM.Database.DbSets.Addresses; using TIAM.Database.DbSets.Addresses;
using TIAM.Database.DbSets.Emails; using TIAM.Database.DbSets.Emails;
using TIAM.Database.DbSets.Transfers; using TIAM.Database.DbSets.Transfers;
using TIAM.Database.DbSets.Users; using TIAM.Database.DbSets.Users;
using TIAM.Entities.Addresses; using TIAM.Entities.Addresses;
using TIAM.Entities.Emails;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
@ -12,5 +12,5 @@ using TIAM.Entities.Users;
namespace TIAM.Database.DbContexts.Users; namespace TIAM.Database.DbContexts.Users;
public interface IUserDbContext : public interface IUserDbContext :
IAcUserDbContextBase<User, Profile, UserToken, Company, UserToCompany, Address, EmailMessage>, IUserDbSet, IAddressDbSet, ITransferDestinationDbSet, ITransferDbSet, IEmailMessageDbSet IAcUserDbContextBase<User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider, Address>, IUserDbSet, IAddressDbSet, ITransferDestinationDbSet, ITransferDbSet, IEmailMessageDbSet
{ } { }

View File

@ -1,32 +1,41 @@
using Microsoft.EntityFrameworkCore; using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using AyCode.Database.DbContexts;
using AyCode.Database.DbContexts.Users;
using AyCode.Database.ModelBuilders.Profiles;
using AyCode.Entities.Users;
using AyCode.Interfaces.Users;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using TIAM.Database.ModelBuilders.Emails; using TIAM.Database.ModelBuilders.Emails;
using TIAM.Database.ModelBuilders.Products; using TIAM.Database.ModelBuilders.Products;
using TIAM.Database.ModelBuilders.Transfers; using TIAM.Database.ModelBuilders.Transfers;
using TIAM.Database.ModelBuilders.Users; using TIAM.Database.ModelBuilders.Users;
using TIAM.Entities.Addresses; using TIAM.Entities.Addresses;
using TIAM.Entities.Emails; using TIAM.Entities.Emails;
using TIAM.Entities.Permissions;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.TransferDestinations;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
using TIAM.Entities.Users; using TIAM.Entities.Users;
namespace TIAM.Database.DbContexts.Users namespace TIAM.Database.DbContexts.Users
{ {
public class UserDbContext : DbContextBase, IUserDbContext public class UserDbContext : DbContextBase, IUserDbContext
//AcUserDbContextBase<User, Profile, UserToken, Company, UserToServiceProvider, Address, EmailMessage>, IUserDbContext
{ {
public DbSet<User> Users { get; set; } public DbSet<User> Users { get; set; }
public DbSet<UserToken> UserTokens { get; set; } public DbSet<UserToken> UserTokens { get; set; }
public DbSet<Address> Addresses { get; set; } public DbSet<Address> Addresses { get; set; }
public DbSet<Profile> Profiles { get; set; }
public DbSet<EmailMessage> EmailMessages { get; set; }
public DbSet<Company> Companies { get; set; }
public DbSet<Transfer> Transfers { get; set; } public DbSet<Transfer> Transfers { get; set; }
public DbSet<TransferToDriver> TransferToDrivers { get; set; } public DbSet<EmailMessage> EmailMessages { get; set; }
public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; }
public DbSet<TransferDestination> TransferDestinations { get; set; } public DbSet<TransferDestination> TransferDestinations { get; set; }
@ -66,27 +75,24 @@ namespace TIAM.Database.DbContexts.Users
new EmailMessageEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<EmailMessage>()); new EmailMessageEntityTypeDefaultConfigurations().Configure(modelBuilder.Entity<EmailMessage>());
//modelBuilder.Entity<TransferDestinationToProduct>().HasOne(e => e.TransferDestination);
//modelBuilder.Entity<TransferDestinationToProduct>().Navigation(e => e.TransferDestination).AutoInclude(true);
//modelBuilder.Entity<Product>().BuildProductToServiceProviderRelation(); //modelBuilder.Entity<Product>().BuildProductToServiceProviderRelation();
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>()); //new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
//modelBuilder.Entity<UserProductMapping>().OwnsOne( modelBuilder.Entity<UserProductMapping>().OwnsOne(
// userToProduct => userToProduct.JsonDetailModel, builderUserProductJsonDetail => userToProduct => userToProduct.JsonDetailModel, builderUserProductJsonDetail =>
// { {
// builderUserProductJsonDetail.ToJson(); builderUserProductJsonDetail.ToJson();
// builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars, builderUserProductToCar => builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars, builderUserProductToCar =>
// { {
// builderUserProductToCar.OwnsOne(userProductToCar => userProductToCar.Car, builderCar => builderUserProductToCar.OwnsOne(userProductToCar => userProductToCar.Car, builderCar =>
// { {
// }); });
// }); });
// //builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars2); //builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars2);
// }); });
} }
} }
} }

View File

@ -1,25 +0,0 @@
using AyCode.Core.Enums;
using AyCode.Core.Loggers;
using AyCode.Database;
using AyCode.Database.DbContexts.Loggers;
using AyCode.Entities.Server.LogItems;
namespace TIAM.Database;
public class LoggerDbContextBase : AcLoggerDbContextBase<AcLogItem>
{
}
public class DbLogItemWriter : AcDbLogItemWriter<LoggerDbContextBase, AcLogItem>
{
public DbLogItemWriter() : this(null)
{ }
public DbLogItemWriter(string? categoryName = null) : base(categoryName)
{ }
public DbLogItemWriter(AppType appType, LogLevel logLevel, string? categoryName = null) : base(appType, logLevel, categoryName)
{
}
}

View File

@ -1,9 +0,0 @@
using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Drivers;
namespace TIAM.Database.DbSets.Cars;
public interface ICarDbSet
{
public DbSet<Car> Cars { get; set; }
}

View File

@ -1,18 +0,0 @@
using AyCode.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbSets.Transfers;
using TIAM.Database.DbSets.Users;
using TIAM.Entities.Drivers;
using TIAM.Entities.Transfers;
using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.Drivers;
public static class DriverDbSetExtensions
{
public static IQueryable<UserProductMapping> GetAllDrivers(this IDriverDbSet ctx, bool autoInclude = true)
=> ctx.UserProductMappingsWithRelations(autoInclude).Where(x => ctx.Cars.Any(car => car.UserProductMappingId == x.Id));
public static IQueryable<UserProductMapping> GetAllDriversByProductId(this IDriverDbSet ctx, Guid productId, bool autoInclude = true)
=> ctx.GetAllDrivers(autoInclude).Where(x => x.ProductId == productId);
}

View File

@ -1,9 +0,0 @@
using TIAM.Database.DbSets.Cars;
using TIAM.Database.DbSets.Transfers;
using TIAM.Database.DbSets.Users;
using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.Drivers;
public interface IDriverDbSet : IUserProductMappingDbSet, ICarDbSet, ITransferToDriverDbSet, ITransferDbSet
{ }

View File

@ -1,46 +1,50 @@
namespace TIAM.Database.DbSets.Emails; using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Emails;
using TIAM.Entities.Products;
//public static class EmailMessageDbSetExtension namespace TIAM.Database.DbSets.Emails;
//{
// public static EmailMessage? GetEmailMessageById(this IEmailMessageDbSet ctx, Guid emailMessageId)
// => ctx.EmailMessages.FirstOrDefault(x => x.Id == emailMessageId);
// public static IQueryable<EmailMessage> GetEmailMessagesByContextId(this IEmailMessageDbSet ctx, Guid contextId) public static class EmailMessageDbSetExtension
// => ctx.EmailMessages.Where(x => x.ContextId == contextId); {
public static EmailMessage? GetEmailMessageById(this IEmailMessageDbSet ctx, Guid emailMessageId)
=> ctx.EmailMessages.FirstOrDefault(x => x.Id == emailMessageId);
// public static IQueryable<EmailMessage> GetEmailMessagesBySenderId(this IEmailMessageDbSet ctx, Guid senderId) public static IQueryable<EmailMessage> GetEmailMessagesByContextId(this IEmailMessageDbSet ctx, Guid contextId)
// => ctx.EmailMessages.Where(x => x.SenderId == senderId); => ctx.EmailMessages.Where(x => x.ContextId == contextId);
// public static IQueryable<EmailMessage> GetEmailMessagesBySenderEmailAddress(this IEmailMessageDbSet ctx, string senderEmailAddress) public static IQueryable<EmailMessage> GetEmailMessagesBySenderId(this IEmailMessageDbSet ctx, Guid senderId)
// => ctx.EmailMessages.Where(x => x.EmailAddress == senderEmailAddress); => ctx.EmailMessages.Where(x => x.SenderId == senderId);
// private static IQueryable<EmailMessage> GetEmailMessages(this IQueryable<EmailMessage> queryableEmails, Guid userId, Guid userProductMappingId) public static IQueryable<EmailMessage> GetEmailMessagesBySenderEmailAddress(this IEmailMessageDbSet ctx, string senderEmailAddress)
// => queryableEmails.Where(x => x.SenderId == userId || x.SenderId == userProductMappingId || x.Recipients.Any(recipient => recipient.RecipientId == userId || recipient.RecipientId == userProductMappingId)); => ctx.EmailMessages.Where(x => x.SenderEmailAddress == senderEmailAddress);
// public static IQueryable<EmailMessage> GetEmailMessages(this IEmailMessageDbSet ctx, Guid userId, Guid userProductMappingId) private static IQueryable<EmailMessage> GetEmailMessages(this IQueryable<EmailMessage> queryableEmails, Guid userId, Guid userProductMappingId)
// => ctx.EmailMessages.GetEmailMessages(userId, userProductMappingId); => queryableEmails.Where(x => x.SenderId == userId || x.SenderId == userProductMappingId || x.Recipients.Any(recipient => recipient.RecipientId == userId || recipient.RecipientId == userProductMappingId));
// public static IQueryable<EmailMessage> GetEmailMessages(this IEmailMessageDbSet ctx, Guid contextId, Guid userId, Guid userProductMappingId) public static IQueryable<EmailMessage> GetEmailMessages(this IEmailMessageDbSet ctx, Guid userId, Guid userProductMappingId)
// => ctx.GetEmailMessagesByContextId(contextId).GetEmailMessages(userId, userProductMappingId); => ctx.EmailMessages.GetEmailMessages(userId, userProductMappingId);
// #region Add, Update, Remove public static IQueryable<EmailMessage> GetEmailMessages(this IEmailMessageDbSet ctx, Guid contextId, Guid userId, Guid userProductMappingId)
=> ctx.GetEmailMessagesByContextId(contextId).GetEmailMessages(userId, userProductMappingId);
// public static bool AddEmailMessage(this IEmailMessageDbSet ctx, EmailMessage emailMessage) #region Add, Update, Remove
// => ctx.EmailMessages.Add(emailMessage).State == EntityState.Added;
// public static bool UpdateEmailMessage(this IEmailMessageDbSet ctx, EmailMessage emailMessage) public static bool AddEmailMessage(this IEmailMessageDbSet ctx, EmailMessage emailMessage)
// => ctx.EmailMessages.Update(emailMessage).State == EntityState.Modified; => ctx.EmailMessages.Add(emailMessage).State == EntityState.Added;
// public static bool RemoveEmailMessage(this IEmailMessageDbSet ctx, Guid emailMessageId) public static bool UpdateEmailMessage(this IEmailMessageDbSet ctx, EmailMessage emailMessage)
// { => ctx.EmailMessages.Update(emailMessage).State == EntityState.Modified;
// var emailMessage = ctx.GetEmailMessageById(emailMessageId);
// return emailMessage == null || ctx.RemoveEmailMessage(emailMessage); public static bool RemoveEmailMessage(this IEmailMessageDbSet ctx, Guid emailMessageId)
// } {
var emailMessage = ctx.GetEmailMessageById(emailMessageId);
// public static bool RemoveEmailMessage(this IEmailMessageDbSet ctx, EmailMessage emailMessage) return emailMessage == null || ctx.RemoveEmailMessage(emailMessage);
// => ctx.EmailMessages.Remove(emailMessage).State == EntityState.Deleted; }
// #endregion Add, Update, Remove public static bool RemoveEmailMessage(this IEmailMessageDbSet ctx, EmailMessage emailMessage)
=> ctx.EmailMessages.Remove(emailMessage).State == EntityState.Deleted;
//} #endregion Add, Update, Remove
}

View File

@ -1,7 +1,10 @@
using AyCode.Database.DbSets.Messages; using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Emails; using TIAM.Entities.Emails;
using TIAM.Entities.Permissions;
namespace TIAM.Database.DbSets.Emails; namespace TIAM.Database.DbSets.Emails;
public interface IEmailMessageDbSet : IAcEmailMessageDbSet<EmailMessage> public interface IEmailMessageDbSet
{ } {
public DbSet<EmailMessage> EmailMessages { get; set; }
}

View File

@ -1,6 +1,11 @@
using AyCode.Database; using AyCode.Database;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using TIAM.Database.DbContexts;
using TIAM.Database.DbContexts.ServiceProviders;
using TIAM.Database.DbSets.Users;
using TIAM.Entities.Permissions; using TIAM.Entities.Permissions;
using TIAM.Entities.Products;
namespace TIAM.Database.DbSets.Permissions; namespace TIAM.Database.DbSets.Permissions;

View File

@ -1,13 +1,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbSets.Profiles;
using TIAM.Database.DbSets.Transfers;
using TIAM.Database.DbSets.Users;
using TIAM.Entities.Addresses;
using TIAM.Entities.Products; using TIAM.Entities.Products;
namespace TIAM.Database.DbSets.Products; namespace TIAM.Database.DbSets.Products;
public interface IProductDbSet : IProfileDbSet, IUserProductMappingDbSet, ITransferDestinationDbSet public interface IProductDbSet
{ {
public DbSet<Product> Products { get; set; } public DbSet<Product> Products { get; set; }
} }

View File

@ -1,16 +1,6 @@
using AyCode.Core.Extensions; using Microsoft.EntityFrameworkCore;
using AyCode.Database.DbSets.Profiles; using Microsoft.Extensions.DependencyInjection;
using AyCode.Interfaces.Addresses;
using AyCode.Interfaces.Entities;
using AyCode.Interfaces.Profiles;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using TIAM.Database.DbSets.Transfers;
using TIAM.Database.DbSets.Users;
using TIAM.Entities.Addresses;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Profiles;
using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.Products; namespace TIAM.Database.DbSets.Products;
@ -19,48 +9,14 @@ public static class ProductDbSetExtensions
#region Add, Update, Remove #region Add, Update, Remove
public static bool AddProduct(this IProductDbSet ctx, Product product) public static bool AddProduct(this IProductDbSet ctx, Product product)
{ => ctx.Products.Add(product).State == EntityState.Added;
if (product.Id.IsNullOrEmpty()) product.Id = Guid.NewGuid();
if (product.Profile == null!)
product.SetProfile((Activator.CreateInstance(typeof(Profile), product.ProfileId, product.Name) as Profile)!);
if (product.Profile!.Address == null!)
product.Profile.SetAddress((Activator.CreateInstance(typeof(Address), product.Profile.AddressId, product.Name) as Address)!);
return ctx.Products.Add(product).State == EntityState.Added;
}
public static bool UpdateProduct(this IProductDbSet ctx, Product product) public static bool UpdateProduct(this IProductDbSet ctx, Product product)
{ => ctx.Products.Update(product).State == EntityState.Modified;
return ctx.Products.Update(product).State == EntityState.Modified;
}
private static bool RemoveProduct(this IProductDbSet ctx, Product product) public static bool RemoveProduct(this IProductDbSet ctx, Product product)
{ => ctx.Products.Remove(product).State == EntityState.Deleted;
ctx.RemoveProfile(product.ProfileId);
ctx.RemoveUserProductMappingsByProductId(product.Id);
ctx.RemoveTransferDestinationToProductByProductId(product.Id);
//TODO: Transfer, etc... - J.
return ctx.Products.Remove(product).State == EntityState.Deleted;
}
public static bool RemoveProduct(this IProductDbSet ctx, Guid productId)
{
var product = ctx.GetProductById(productId);
return product == null || ctx.RemoveProduct(product);
}
public static bool RemoveProductsByCompanyId(this IProductDbSet ctx, Guid companyId)
{
var products = ctx.GetProductsByCompanyId(companyId);
foreach (var product in products)
ctx.RemoveProduct(product);
return true;
}
#endregion Add, Update, Remove #endregion Add, Update, Remove
public static IQueryable<Product> ProductsWithUserRelations(this IProductDbSet ctx, bool autoInclude = true) public static IQueryable<Product> ProductsWithUserRelations(this IProductDbSet ctx, bool autoInclude = true)
@ -73,7 +29,7 @@ public static class ProductDbSetExtensions
public static Product? GetProductById(this IProductDbSet ctx, Guid productId, bool includeUsers = true) public static Product? GetProductById(this IProductDbSet ctx, Guid productId, bool includeUsers = true)
=> ctx.ProductsWithUserRelations(includeUsers).FirstOrDefault(x => x.Id == productId); => ctx.ProductsWithUserRelations(includeUsers).FirstOrDefault(x => x.Id == productId);
public static IQueryable<Product> GetProductsByCompanyId(this IProductDbSet ctx, Guid serviceProviderId, bool includeUsers = true) public static IQueryable<Product> GetProductsByServiceProviderId(this IProductDbSet ctx, Guid serviceProviderId, bool includeUsers = true)
=> ctx.ProductsWithUserRelations(includeUsers).Where(x => x.ServiceProviderId == serviceProviderId); => ctx.ProductsWithUserRelations(includeUsers).Where(x => x.ServiceProviderId == serviceProviderId);
} }

View File

@ -1,10 +0,0 @@
using AyCode.Database.DbSets.Profiles;
using TIAM.Database.DbSets.Addresses;
using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles;
namespace TIAM.Database.DbSets.Profiles;
public interface IProfileDbSet : IAcProfileDbSetBase<Profile, Address>, IAddressDbSet
{
}

View File

@ -1,41 +0,0 @@
namespace TIAM.Database.DbSets.ServiceProvider;
//public static class CompanyDbSetExtensions
//{
// #region Add, Update, Remove
// public static bool AddServiceProvider(this ICompanyDbSet ctx, Company company)
// {
// var companyProfile = company.Profile;
// if (company.ProfileId.IsNullOrEmpty() || companyProfile.Id != company.ProfileId || companyProfile.AddressId.IsNullOrEmpty() || companyProfile.Address.Id != companyProfile.AddressId)
// {
// return false;
// }
// if (!company.OwnerId.IsNullOrEmpty())
// company.AddUser(company.OwnerId.Value, 1);
// return ctx.Companies.Add(company).State == EntityState.Added;
// }
// public static bool RemoveServiceProvider(this ICompanyDbSet ctx, Company company)
// => ctx.Companies.Remove(company).State == EntityState.Deleted;
// public static bool RemoveServiceProvider(this ICompanyDbSet ctx, Guid companyId)
// {
// var company = ctx.GetServiceProviderById(companyId);
// return company == null || ctx.RemoveServiceProvider(company);
// }
// #endregion Add, Update, Remove
// public static Company? GetServiceProviderById(this ICompanyDbSet ctx, Guid companyId)
// => ctx.Companies.FirstOrDefault(x => x.Id == companyId);
// public static IQueryable<Company> GetServiceProviders(this ICompanyDbSet ctx)
// => ctx.Companies;
// public static List<Company> GetServiceProvidersByOwnerId(this ICompanyDbSet ctx, Guid ownerId)
// => ctx.Companies.Where(x => x.OwnerId == ownerId).ToList();
//}

View File

@ -1,11 +0,0 @@
using AyCode.Database.DbSets.Companies;
using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.ServiceProvider;
public interface ICompanyDbSet : IAcCompanyDbSetBase<Company, Profile, Address, UserToCompany>
{
}

View File

@ -0,0 +1,9 @@
using Microsoft.EntityFrameworkCore;
using TIAM.Entities.ServiceProviders;
namespace TIAM.Database.DbSets.ServiceProvider;
public interface IServiceProviderDbSet
{
public DbSet<TiamServiceProvider> ServiceProviders { get; set; }
}

View File

@ -1,9 +1,10 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Entities.TransferDestinations;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
namespace TIAM.Database.DbSets.Transfers; namespace TIAM.Database.DbSets.Transfers;
public interface ITransferDbSet : ITransferToDriverDbSet public interface ITransferDbSet
{ {
public DbSet<Transfer> Transfers { get; set; } public DbSet<Transfer> Transfers { get; set; }
} }

View File

@ -1,10 +1,10 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbSets.Addresses; using TIAM.Entities.Products;
using TIAM.Entities.Transfers; using TIAM.Entities.TransferDestinations;
namespace TIAM.Database.DbSets.Transfers; namespace TIAM.Database.DbSets.Transfers;
public interface ITransferDestinationDbSet : IAddressDbSet, ITransferDestinationToProductDbSet public interface ITransferDestinationDbSet
{ {
public DbSet<TransferDestination> TransferDestinations { get; set; } public DbSet<TransferDestination> TransferDestinations { get; set; }
} }

View File

@ -1,9 +0,0 @@
using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Transfers;
namespace TIAM.Database.DbSets.Transfers;
public interface ITransferDestinationToProductDbSet
{
public DbSet<TransferDestinationToProduct> TransferDestinationToProducts { get; set; }
}

View File

@ -1,9 +0,0 @@
using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Transfers;
namespace TIAM.Database.DbSets.Transfers;
public interface ITransferToDriverDbSet
{
public DbSet<TransferToDriver> TransferToDrivers { get; set; }
}

View File

@ -1,6 +1,8 @@
using DevExpress.Utils.Serializing; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using TIAM.Database.DbSets.Products;
using TIAM.Core.Enums; using TIAM.Database.DbSets.Users;
using TIAM.Entities.Products;
using TIAM.Entities.TransferDestinations;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
namespace TIAM.Database.DbSets.Transfers; namespace TIAM.Database.DbSets.Transfers;
@ -15,126 +17,27 @@ public static class TransferDbSetExtensions
public static bool UpdateTransfer(this ITransferDbSet ctx, Transfer transfer) public static bool UpdateTransfer(this ITransferDbSet ctx, Transfer transfer)
=> ctx.Transfers.Update(transfer).State == EntityState.Modified; => ctx.Transfers.Update(transfer).State == EntityState.Modified;
public static bool UpdateTransferStatus(this ITransferDbSet ctx, Guid transferId, TransferStatusType transferStatusType, bool onlyStatusLowerThanNew = true) public static bool RemoveTransfer(this ITransferDbSet ctx, Transfer transfer)
{ => ctx.Transfers.Remove(transfer).State == EntityState.Deleted;
var transfer = ctx.Transfers.FirstOrDefault(x => x.Id == transferId);
return transfer != null && ctx.UpdateTransferStatus(transfer, transferStatusType);
}
public static bool UpdateTransferStatus(this ITransferDbSet ctx, Transfer transfer, TransferStatusType transferStatusType, bool onlyStatusLowerThanNew = true)
{
if (transfer.TransferStatusType == transferStatusType || (onlyStatusLowerThanNew && transfer.TransferStatusType > transferStatusType)) return true;
transfer.TransferStatusType = transferStatusType;
return ctx.Transfers.Update(transfer).State == EntityState.Modified;
}
private static bool RemoveTransfer(this ITransferDbSet ctx, Transfer transfer)
{
ctx.TransferToDrivers.RemoveRange(ctx.TransferToDrivers.Where(x => x.TransferId == transfer.Id));
return ctx.Transfers.Remove(transfer).State == EntityState.Deleted;
}
public static bool RemoveTransfer(this ITransferDbSet ctx, Guid transferId) public static bool RemoveTransfer(this ITransferDbSet ctx, Guid transferId)
{ {
var transfer = ctx.GetTransferById(transferId); var transfer = ctx.GetTransferById(transferId, false);
return transfer == null || ctx.RemoveTransfer(transfer); return transfer == null || ctx.RemoveTransfer(transfer);
} }
#endregion Add, Update, Remove #endregion Add, Update, Remove
public static IQueryable<Transfer> GetTransfersByUserId(this ITransferDbSet ctx, Guid userId) public static Transfer? GetTransferById(this ITransferDbSet ctx, Guid transferId, bool autoInclude = false)
=> ctx.GetTransfers().Where(x => x.UserId == userId);
public static IQueryable<Transfer> GetTransfersByDriverUserId(this ITransferDbSet ctx, Guid driverUserId)
=> ctx.GetTransfers().Where(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMapping.UserId == driverUserId));
public static IQueryable<Transfer> GetTransfersByProductId(this ITransferDbSet ctx, Guid productId)
=> ctx.GetTransfers().Where(x => x.ProductId == productId);
public static IQueryable<Transfer> GetTransfersByUserProductMappingId(this ITransferDbSet ctx, Guid userProductMappingId)
=> ctx.GetTransfers().Where(x => x.TransferToDrivers.Any(ttd => ttd.UserProductMappingId == userProductMappingId));
public static Transfer? GetTransferById(this ITransferDbSet ctx, Guid transferId)
=> ctx.Transfers.FirstOrDefault(x => x.Id == transferId); => ctx.Transfers.FirstOrDefault(x => x.Id == transferId);
public static IQueryable<Transfer> GetTransfers(this ITransferDbSet ctx) public static IQueryable<Transfer> GetTransfers(this ITransferDbSet ctx)
=> ctx.Transfers; => ctx.Transfers;
#region TransferDestination
public static TransferDestination? GetTransferDestinationById(this ITransferDestinationDbSet ctx, Guid transferDestinationId) public static TransferDestination? GetTransferDestinationById(this ITransferDestinationDbSet ctx, Guid transferDestinationId)
=> ctx.TransferDestinations.FirstOrDefault(x => x.Id == transferDestinationId); => ctx.TransferDestinations.FirstOrDefault(x => x.Id == transferDestinationId);
public static IQueryable<TransferDestination> GetTransferDestinations(this ITransferDestinationDbSet ctx) public static IQueryable<TransferDestination> GetTransferDestinations(this ITransferDestinationDbSet ctx)
=> ctx.TransferDestinations; => ctx.TransferDestinations;
public static bool AddTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination)
=> ctx.TransferDestinations.Add(transferDestination).State == EntityState.Added;
public static bool UpdateTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination)
=> ctx.TransferDestinations.Update(transferDestination).State == EntityState.Modified;
private static bool RemoveTransferDestination(this ITransferDestinationDbSet ctx, TransferDestination transferDestination, bool removeAddress)
{
if (removeAddress) ctx.Addresses.Remove(transferDestination.Address);
ctx.RemoveTransferDestinationToProductByTransferDestinationId(transferDestination.Id);
return ctx.TransferDestinations.Remove(transferDestination).State == EntityState.Deleted;
}
public static bool RemoveTransferDestination(this ITransferDestinationDbSet ctx, Guid transferDestinationId, bool removeAddress)
{
var transferDestination = ctx.GetTransferDestinationById(transferDestinationId);
return transferDestination == null || ctx.RemoveTransferDestination(transferDestination, removeAddress);
}
#endregion TransferDestination
#region TransferDestinationToProduct
public static TransferDestinationToProduct? GetTransferDestinationToProductById(this ITransferDestinationToProductDbSet ctx, Guid transferDestinationToProductId)
=> ctx.TransferDestinationToProducts.FirstOrDefault(x => x.Id == transferDestinationToProductId);
public static TransferDestinationToProduct? GetTransferDestinationToProduct(this ITransferDestinationToProductDbSet ctx, Guid productId, Guid transferDestinationId)
=> ctx.TransferDestinationToProducts.FirstOrDefault(x => x.ProductId == productId && x.TransferDestinationId == transferDestinationId);
public static IQueryable<TransferDestinationToProduct> GetTransferDestinationToProducts(this ITransferDestinationToProductDbSet ctx)
=> ctx.TransferDestinationToProducts;
public static IQueryable<TransferDestinationToProduct> GetTransferDestinationToProductsByProductId(this ITransferDestinationToProductDbSet ctx, Guid productId)
=> ctx.TransferDestinationToProducts.Where(x => x.ProductId == productId);
public static IQueryable<TransferDestinationToProduct> GetTransferDestinationToProductsByTransferDestinationId(this ITransferDestinationToProductDbSet ctx, Guid transferDestinationId)
=> ctx.TransferDestinationToProducts.Where(x => x.TransferDestinationId == transferDestinationId);
public static bool AddTransferDestinationToProduct(this ITransferDestinationToProductDbSet ctx, TransferDestinationToProduct transferDestinationToProduct)
=> ctx.TransferDestinationToProducts.Add(transferDestinationToProduct).State == EntityState.Added;
public static bool UpdateTransferDestinationToProduct(this ITransferDestinationToProductDbSet ctx, TransferDestinationToProduct transferDestinationToProduct)
=> ctx.TransferDestinationToProducts.Update(transferDestinationToProduct).State == EntityState.Modified;
private static bool RemoveTransferDestinationToProduct(this ITransferDestinationToProductDbSet ctx, TransferDestinationToProduct transferDestinationToProduct)
{
return ctx.TransferDestinationToProducts.Remove(transferDestinationToProduct).State == EntityState.Deleted;
}
public static bool RemoveTransferDestinationToProduct(this ITransferDestinationToProductDbSet ctx, Guid transferDestinationToProductId)
{
var transferDestinationToProduct = ctx.GetTransferDestinationToProductById(transferDestinationToProductId);
return transferDestinationToProduct == null || ctx.RemoveTransferDestinationToProduct(transferDestinationToProduct);
}
public static bool RemoveTransferDestinationToProductByProductId(this ITransferDestinationToProductDbSet ctx, Guid productId)
{
ctx.TransferDestinationToProducts.RemoveRange(ctx.TransferDestinationToProducts.Where(x => x.ProductId == productId));
return true;
}
public static bool RemoveTransferDestinationToProductByTransferDestinationId(this ITransferDestinationToProductDbSet ctx, Guid transferDestinationId)
{
ctx.TransferDestinationToProducts.RemoveRange(ctx.TransferDestinationToProducts.Where(x => x.TransferDestinationId == transferDestinationId));
return true;
}
#endregion TransferDestinationToProduct
} }

View File

@ -1,49 +0,0 @@
using Microsoft.EntityFrameworkCore;
using TIAM.Core.Enums;
using TIAM.Database.DbSets.Drivers;
using TIAM.Database.DbSets.Users;
using TIAM.Entities.Transfers;
using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.Transfers;
public static class TransferToDriverDbSetExtensions
{
#region TransferToDriver
public static TransferToDriver? GetTransferToDriverById(this ITransferToDriverDbSet ctx, Guid transferToDriverId, bool autoInclude = true)
=> ctx.TransferToDrivers.FirstOrDefault(x => x.Id == transferToDriverId);
public static IQueryable<TransferToDriver> GetTransferToDriversByTransferId(this ITransferToDriverDbSet ctx, Guid transferId, bool autoInclude = true)
=> ctx.TransferToDrivers.Where(x => x.TransferId == transferId);
public static IQueryable<TransferToDriver> GetTransferToDriversByUpmId(this ITransferToDriverDbSet ctx, Guid upmId, bool autoInclude = true)
=> ctx.TransferToDrivers.Where(x => x.UserProductMappingId == upmId);
public static bool AddTransferToDriver(this ITransferDbSet ctx, TransferToDriver transferToDriver)
{
ctx.UpdateTransferStatus(transferToDriver.TransferId, TransferStatusType.AssignedToDriver);
return ctx.TransferToDrivers.Add(transferToDriver).State == EntityState.Added;
}
public static bool UpdateTransferToDriver(this ITransferDbSet ctx, TransferToDriver transferToDriver)
{
ctx.UpdateTransferStatus(transferToDriver.Transfer, TransferStatusType.AssignedToDriver);
return ctx.TransferToDrivers.Update(transferToDriver).State == EntityState.Modified;
}
private static bool RemoveTransferToDriver(this ITransferDbSet ctx, TransferToDriver transferToDriver)
{
//TODO: TransferStatusType change, ha nincs sofőr a törlés után! - J.
return ctx.TransferToDrivers.Remove(transferToDriver).State == EntityState.Deleted;
}
public static bool RemoveTransferToDriver(this ITransferDbSet ctx, Guid transferToDriverId)
{
var transferToDriver = ctx.GetTransferToDriverById(transferToDriverId);
return transferToDriver == null || ctx.RemoveTransferToDriver(transferToDriver);
}
#endregion TransferToDriver
}

View File

@ -6,6 +6,6 @@ using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.Users; namespace TIAM.Database.DbSets.Users;
public interface IUserDbSet : IAcUserDbSetBase<User, Profile, Company, UserToCompany, Address> public interface IUserDbSet : IAcUserDbSet<User, Profile, TiamServiceProvider, UserToServiceProvider, Address>
{ {
} }

View File

@ -1,10 +1,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbSets.Transfers;
using TIAM.Entities.Users; using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.Users; namespace TIAM.Database.DbSets.Users;
public interface IUserProductMappingDbSet : ITransferToDriverDbSet public interface IUserProductMappingDbSet
{ {
public DbSet<UserProductMapping> UserProductMappings { get; set; } public DbSet<UserProductMapping> UserProductMappings { get; set; }
} }

View File

@ -1,4 +1,5 @@
using AyCode.Database.DbSets.Users; using AyCode.Database.DbSets.Users;
using AyCode.Entities.Users;
using TIAM.Entities.Users; using TIAM.Entities.Users;
namespace TIAM.Database.DbSets.Users; namespace TIAM.Database.DbSets.Users;

View File

@ -1,5 +1,8 @@
using Microsoft.EntityFrameworkCore; using System.Security.Cryptography.X509Certificates;
using AyCode.Database.DbSets.Users;
using Microsoft.EntityFrameworkCore;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users;
namespace TIAM.Database.DbSets.Users; namespace TIAM.Database.DbSets.Users;
@ -17,4 +20,14 @@ public static class UserDbSetExtensions
public static User? GetUserByEmail(this IUserDbSet ctx, string email, bool autoInclude) public static User? GetUserByEmail(this IUserDbSet ctx, string email, bool autoInclude)
=> ctx.UsersWithProductRelations(autoInclude).FirstOrDefault(x => x.EmailAddress == email); => ctx.UsersWithProductRelations(autoInclude).FirstOrDefault(x => x.EmailAddress == email);
public static UserModelDto? GetUserModelDtoById(this IUserDbSet ctx, Guid userId)
=> ctx.GetUsersById(userId).Select(user => new UserModelDto(user)).FirstOrDefault();
public static UserModelDto? GetUserModelDtoByEmail(this IUserDbSet ctx, string email)
=> ctx.GetUsersByEmail(email).Select(user => new UserModelDto(user)).FirstOrDefault();
public static IQueryable<UserModelDto> GetAllUsersModelDto(this IUserDbSet ctx)
=> ctx.Users.Select(user => new UserModelDto(user));
} }

View File

@ -1,6 +1,6 @@
using AyCode.Core.Extensions; using AyCode.Utils.Extensions;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TIAM.Database.DbSets.Transfers; using TIAM.Database.DbContexts.ServiceProviders;
using TIAM.Entities.Drivers; using TIAM.Entities.Drivers;
using TIAM.Entities.Users; using TIAM.Entities.Users;
@ -26,6 +26,7 @@ public static class UserProductMappingDbSetExtensions
public static IQueryable<UserProductMapping> GetUserProductMappingsByProductId(this IUserProductMappingDbSet ctx, Guid productId, bool autoInclude = true) public static IQueryable<UserProductMapping> GetUserProductMappingsByProductId(this IUserProductMappingDbSet ctx, Guid productId, bool autoInclude = true)
=> ctx.UserProductMappingsWithRelations(autoInclude).Where(x => x.ProductId == productId); => ctx.UserProductMappingsWithRelations(autoInclude).Where(x => x.ProductId == productId);
public static bool AddUserProductMapping(this IUserProductMappingDbSet ctx, UserProductMapping userProductMapping) public static bool AddUserProductMapping(this IUserProductMappingDbSet ctx, UserProductMapping userProductMapping)
{ {
if (userProductMapping.UserId.IsNullOrEmpty() || userProductMapping.ProductId.IsNullOrEmpty() || userProductMapping.Permissions < 0) if (userProductMapping.UserId.IsNullOrEmpty() || userProductMapping.ProductId.IsNullOrEmpty() || userProductMapping.Permissions < 0)
@ -70,9 +71,6 @@ public static class UserProductMappingDbSetExtensions
{ {
if (userProductMapping == null) return false; if (userProductMapping == null) return false;
if (ctx.GetTransferToDriversByUpmId(userProductMapping.Id).Any())
return false;
return ctx.UserProductMappings.Remove(userProductMapping).State == EntityState.Deleted; return ctx.UserProductMappings.Remove(userProductMapping).State == EntityState.Deleted;
} }
@ -89,10 +87,4 @@ public static class UserProductMappingDbSetExtensions
return userProductMapping == null || ctx.RemoveUserProductMapping(userProductMapping); return userProductMapping == null || ctx.RemoveUserProductMapping(userProductMapping);
} }
public static bool RemoveUserProductMappingsByProductId(this IUserProductMappingDbSet ctx, Guid productId)
{
ctx.UserProductMappings.RemoveRange(ctx.UserProductMappings.Where(x=>x.ProductId == productId));
return true;
}
} }

View File

@ -1,5 +0,0 @@
namespace TIAM.Database.ModelBuilders.Companies;
public static class CompanyEntityTypeBuilderExtensions
{
}

View File

@ -1,20 +0,0 @@
using AyCode.Database.ModelBuilders.Users;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
namespace TIAM.Database.ModelBuilders.Companies;
public class CompanyEntityTypeDefaultConfiguration : AcCompanyEntityTypeDefaultConfiguration<Company, Profile, Address, UserToCompany, User> //IAcEntityTypeConfiguration<User>//
{
public override void Configure(EntityTypeBuilder<Company> builder)
{
base.Configure(builder);
//builder
}
}

View File

@ -1,6 +1,8 @@
using AyCode.Database.DbContexts; using AyCode.Database.DbContexts;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TIAM.Database.ModelBuilders.Products;
using TIAM.Entities.Emails; using TIAM.Entities.Emails;
using TIAM.Entities.Products;
namespace TIAM.Database.ModelBuilders.Emails; namespace TIAM.Database.ModelBuilders.Emails;

View File

@ -1,8 +1,7 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders; using System.Security.Cryptography.X509Certificates;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using AyCode.Database.ModelBuilders.Users;
using TIAM.Entities.Profiles;
namespace TIAM.Database.ModelBuilders.Products; namespace TIAM.Database.ModelBuilders.Products;
@ -27,8 +26,6 @@ public static class ProductEntityTypeBuilderExtensions
public static void BuildProductToServiceProviderRelation(this EntityTypeBuilder<Product> modelBuilder, bool autoInclude = true) public static void BuildProductToServiceProviderRelation(this EntityTypeBuilder<Product> modelBuilder, bool autoInclude = true)
{ {
//modelBuilder.BuildEntityToServiceProviderRelation
modelBuilder modelBuilder
.HasOne(x => x.ServiceProvider) .HasOne(x => x.ServiceProvider)
.WithMany(x => x.Products) .WithMany(x => x.Products)
@ -41,8 +38,7 @@ public static class ProductEntityTypeBuilderExtensions
{ {
//modelBuilder.HasOne(x => x.Profile) //modelBuilder.HasOne(x => x.Profile)
modelBuilder.BuildEntityToProfileRelation<Product, Profile>(); modelBuilder.Navigation(e => e.Profile).AutoInclude(autoInclude);
//modelBuilder.Navigation(e => e.Profile).AutoInclude(autoInclude);
} }
#endregion Product #endregion Product

View File

@ -1,6 +1,9 @@
using AyCode.Database.DbContexts; using AyCode.Database.DbContexts;
using AyCode.Database.ModelBuilders.Users;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TIAM.Database.ModelBuilders.Users;
using TIAM.Entities.Products; using TIAM.Entities.Products;
using TIAM.Entities.Users;
namespace TIAM.Database.ModelBuilders.Products; namespace TIAM.Database.ModelBuilders.Products;

View File

@ -1,23 +1,23 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using TIAM.Database.ModelBuilders.Users;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
using TIAM.Entities.Users;
namespace TIAM.Database.ModelBuilders.Transfers; namespace TIAM.Database.ModelBuilders.Transfers;
public static class TransferEntityTypeBuilderExtensions public static class TransferEntityTypeBuilderExtensions
{ {
/// <summary> /// <summary>
/// Mapping Transfer to Drivers relation /// Mapping Transfer to UserProductMapping relation
/// </summary> /// </summary>
public static void BuildTransferToDriversMappingToRelation(this EntityTypeBuilder<Transfer> modelBuilder, bool autoInclude) public static void BuildTransferToProductMappingToRelation(this EntityTypeBuilder<Transfer> modelBuilder, bool autoInclude)
{ {
modelBuilder modelBuilder
.HasMany(x => x.TransferToDrivers) .HasOne(x => x.UserProductMapping)
.WithOne(x => x.Transfer) .WithMany(x => x.Transfers)
.HasForeignKey(x=>x.TransferId) .HasForeignKey(x => x.UserProductMappingId);
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Navigation(e => e.TransferToDrivers).AutoInclude(autoInclude); modelBuilder.Navigation(e => e.UserProductMapping).AutoInclude(autoInclude);
} }
} }

View File

@ -1,6 +1,6 @@
using AyCode.Database.DbContexts; using AyCode.Database.DbContexts;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TIAM.Entities.Products;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
namespace TIAM.Database.ModelBuilders.Transfers; namespace TIAM.Database.ModelBuilders.Transfers;
@ -9,9 +9,6 @@ public class TransferEntityTypeDefaultConfigurations: IAcEntityTypeConfiguration
{ {
public void Configure(EntityTypeBuilder<Transfer> builder) public void Configure(EntityTypeBuilder<Transfer> builder)
{ {
builder.Property(e => e.OrderId).Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore); builder.BuildTransferToProductMappingToRelation(true);
//builder.BuildTransferToProductMappingToRelation(true);
builder.BuildTransferToDriversMappingToRelation(true);
} }
} }

View File

@ -1,4 +1,10 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders; using AyCode.Interfaces.Users;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System.Numerics;
using AyCode.Interfaces.Profiles;
using TIAM.Entities.Products;
using TIAM.Entities.Transfers;
using TIAM.Entities.Users; using TIAM.Entities.Users;
namespace TIAM.Database.ModelBuilders.Users; namespace TIAM.Database.ModelBuilders.Users;
@ -67,11 +73,11 @@ public static class UserEntityTypeBuilderExtensions
/// </summary> /// </summary>
public static void BuildTransferToUserProductMappingRelation(this EntityTypeBuilder<UserProductMapping> modelBuilder, bool autoInclude) public static void BuildTransferToUserProductMappingRelation(this EntityTypeBuilder<UserProductMapping> modelBuilder, bool autoInclude)
{ {
//modelBuilder modelBuilder
// .HasMany(e => e.Transfers) .HasMany(e => e.Transfers)
// .WithOne(e => e.UserProductMapping).HasForeignKey(x => x.UserProductMappingId); .WithOne(e => e.UserProductMapping).HasForeignKey(x => x.UserProductMappingId);
//modelBuilder.Navigation(e => e.Transfers).AutoInclude(autoInclude); modelBuilder.Navigation(e => e.Transfers).AutoInclude(autoInclude);
} }
#endregion UserProductMapping #endregion UserProductMapping

View File

@ -1,11 +1,13 @@
using AyCode.Database.DbContexts; using AyCode.Database.DbContexts;
using AyCode.Database.ModelBuilders.Profiles;
using AyCode.Database.ModelBuilders.Users; using AyCode.Database.ModelBuilders.Users;
using AyCode.Interfaces.Users;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TIAM.Entities.Addresses; using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using static AyCode.Database.ModelBuilders.Profiles.AcProfileEntityTypeConfigurations;
namespace TIAM.Database.ModelBuilders.Users; namespace TIAM.Database.ModelBuilders.Users;
@ -14,7 +16,7 @@ public class UserProductMappingEntityTypeDefaultConfiguration : IAcEntityTypeCon
public void Configure(EntityTypeBuilder<UserProductMapping> builder) public void Configure(EntityTypeBuilder<UserProductMapping> builder)
{ {
builder.BuildUserProductMappingToRelations(false); builder.BuildUserProductMappingToRelations(false);
//builder.BuildTransferToUserProductMappingRelation(true); builder.BuildTransferToUserProductMappingRelation(true);
} }
} }
@ -25,7 +27,7 @@ public class UserProductMappingEntityTypeTransferConfiguration : IAcEntityTypeCo
builder.BuildUserProductMappingToRelations(false); builder.BuildUserProductMappingToRelations(false);
} }
} }
public class UserEntityTypeDefaultConfiguration : AcUserEntityTypeDefaultConfiguration<User, Profile, Company, UserToCompany, Address> //IAcEntityTypeConfiguration<User>// public class UserEntityTypeDefaultConfiguration : AcUserEntityTypeDefaultConfiguration<User, Profile, TiamServiceProvider, UserToServiceProvider, Address> //IAcEntityTypeConfiguration<User>//
{ {
public override void Configure(EntityTypeBuilder<User> builder) public override void Configure(EntityTypeBuilder<User> builder)
{ {

View File

@ -7,11 +7,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DevExpress.Data" Version="24.2.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="MessagePack.Annotations" Version="2.5.187" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>
@ -20,6 +18,7 @@
<Folder Include="DataLayers\Permissions\" /> <Folder Include="DataLayers\Permissions\" />
<Folder Include="DataLayers\Products\" /> <Folder Include="DataLayers\Products\" />
<Folder Include="DbSets\Addresses\" /> <Folder Include="DbSets\Addresses\" />
<Folder Include="DbSets\ServiceProvider\" />
<Folder Include="Extensions\" /> <Folder Include="Extensions\" />
<Folder Include="ModelBuilders\Emails\" /> <Folder Include="ModelBuilders\Emails\" />
<Folder Include="ModelBuilders\Profiles\" /> <Folder Include="ModelBuilders\Profiles\" />
@ -60,6 +59,12 @@
<Reference Include="AyCode.Models.Server"> <Reference Include="AyCode.Models.Server">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.Server.dll</HintPath> <HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.Server.dll</HintPath>
</Reference> </Reference>
<Reference Include="AyCode.Services">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Services.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services.Server">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Services.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Utils"> <Reference Include="AyCode.Utils">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Utils.dll</HintPath> <HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Utils.dll</HintPath>
</Reference> </Reference>

View File

@ -1,68 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Data" Version="24.2.3" />
<PackageReference Include="MessagePack.Annotations" Version="2.5.187" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="DataLayers\DTOs\" />
<Folder Include="DataLayers\Permissions\" />
<Folder Include="DataLayers\Products\" />
<Folder Include="DbSets\Addresses\" />
<Folder Include="Extensions\" />
<Folder Include="ModelBuilders\Emails\" />
<Folder Include="ModelBuilders\Profiles\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TIAM.Core\TIAM.Core.csproj" />
<ProjectReference Include="..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" />
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
<ProjectReference Include="..\TIAM.Models\TIAM.Models.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="AyCode.Core">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Core.dll</HintPath>
</Reference>
<Reference Include="AyCode.Core.Server">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Core.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Database">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Database.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Entities.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities.Server">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Entities.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Interfaces">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Interfaces.dll</HintPath>
</Reference>
<Reference Include="AyCode.Interfaces.Server">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Interfaces.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Models">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.dll</HintPath>
</Reference>
<Reference Include="AyCode.Models.Server">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Utils">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Utils.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@ -1,23 +1,7 @@
using AyCode.Entities.Addresses; using AyCode.Entities.Addresses;
using System.ComponentModel.DataAnnotations.Schema;
namespace TIAM.Entities.Addresses; namespace TIAM.Entities.Addresses;
[Table(nameof(Address))]
public class Address : AcAddress, IAddress public class Address : AcAddress, IAddress
{ {
public Address() : base()
{ }
public Address(Guid id) : base(id)
{
}
public Address(Guid id, string? addressText) : base(id, addressText)
{
}
public Address(Guid id, double? latitude, double? longitude, string? addressText) : base(id, latitude, longitude, addressText)
{
}
} }

View File

@ -1,4 +1,7 @@
using AyCode.Interfaces.Addresses; using AyCode.Interfaces.Addresses;
using AyCode.Interfaces.Addresses.Dtos;
using AyCode.Interfaces.Profiles;
using TIAM.Entities.Profiles;
namespace TIAM.Entities.Addresses; namespace TIAM.Entities.Addresses;

View File

@ -1,5 +1,11 @@
using System.ComponentModel.DataAnnotations; using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Entities.Users;
using AyCode.Interfaces.Entities; using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo; using AyCode.Interfaces.TimeStampInfo;

View File

@ -1,21 +1,15 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
using AyCode.Interfaces.Entities; using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo; using AyCode.Interfaces.TimeStampInfo;
using TIAM.Core.Enums; using TIAM.Core.Enums;
using TIAM.Entities.Users;
namespace TIAM.Entities.Drivers namespace TIAM.Entities.Drivers
{ {
[Table(nameof(Car))] public class Car : IEntityGuid//, ITimeStampInfo, ITimeStampDisableAutoSet
public class Car : IEntityGuid, ITimeStampInfo, IUserProductMappingsRelation//, ITimeStampDisableAutoSet
{ {
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)] //[NotMapped]
public Guid Id { get; set; } = Guid.NewGuid(); public Guid Id { get; set; } = Guid.NewGuid();
public Guid UserProductMappingId { get; set; }
public virtual UserProductMapping UserProductMapping { get; set; }
public int CountryCode { get; set; } = 36; public int CountryCode { get; set; } = 36;
public string LicencePlate { get; set; } = "JGH452"; public string LicencePlate { get; set; } = "JGH452";
@ -24,13 +18,10 @@ namespace TIAM.Entities.Drivers
public string CarModel { get; set; } = "Mondeo"; public string CarModel { get; set; } = "Mondeo";
public int YearOfMake { get; set; } = 2021; public int YearOfMake { get; set; } = 2021;
public byte SeatNumber { get; set; } = 5; public int SeatNumber { get; set; } = 5;
public CarMotorType CarMotorType { get; set; } = CarMotorType.Diesel; public CarMotorType CarMotorType { get; set; } = CarMotorType.Diesel;
//public string Tulajdonos { get; set; }
//public string Üzembentartó { get; set; }
public DateTime Created { get; set; } = DateTime.UtcNow; public DateTime Created { get; set; } = DateTime.UtcNow;
public DateTime Modified { get; set; } = DateTime.UtcNow; public DateTime Modified { get; set; } = DateTime.UtcNow;
} }

View File

@ -1,11 +0,0 @@
namespace TIAM.Entities.Drivers;
public interface ICarForeignKey
{
Guid CarId { get; set; }
}
public interface ICarRelation : ICarForeignKey
{
Car Car { get; set; }
}

View File

@ -1,12 +1,10 @@
using System.ComponentModel.DataAnnotations.Schema; namespace TIAM.Entities.Drivers;
namespace TIAM.Entities.Drivers;
public class UserProductJsonDetailModel public class UserProductJsonDetailModel
{ {
//public string Value { get; set; } = "ANYÁD!!!"; //public string Value { get; set; } = "ANYÁD!!!";
[NotMapped] //[NotMapped]
public List<UserProductToCar>? Cars { get; set; } public List<UserProductToCar>? Cars { get; set; }
//public List<UserProductToCarTest>? Cars2 { get; set; } //public List<UserProductToCarTest>? Cars2 { get; set; }

View File

@ -1,4 +1,9 @@
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo;
using Microsoft.EntityFrameworkCore;
namespace TIAM.Entities.Drivers; namespace TIAM.Entities.Drivers;
@ -11,7 +16,7 @@ public class UserProductToCar //: IEntityGuid//, ITimeStampInfo, ITimeStampDisab
/// </summary> /// </summary>
public Guid UserProductCarId { get; set; } public Guid UserProductCarId { get; set; }
[NotMapped] //[NotMapped, JsonIgnore]
//public Guid UserProductMappingId { get; set; } //public Guid UserProductMappingId { get; set; }
public Car Car { get; set; } public Car Car { get; set; }

View File

@ -1,16 +1,42 @@
using System.ComponentModel.DataAnnotations.Schema; using System.Collections.Specialized;
using AyCode.Entities.Messages; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo;
namespace TIAM.Entities.Emails; namespace TIAM.Entities.Emails;
[Table(nameof(EmailMessage))] [Table(nameof(EmailMessage))]
public class EmailMessage : AcEmailMessage<EmailRecipient> //IEntityGuid, ITimeStampInfo, IEmailRecipientsRelation, IEmailAddress public class EmailMessage : IEntityGuid, ITimeStampInfo, IEmailRecipientsRelation
{ {
public EmailMessage() public EmailMessage()
{ {
} }
public EmailMessage(Guid id, Guid? senderId, Guid contextId, string subject, string? text, string emailAddress) : base(id, senderId, contextId, subject, text, emailAddress) public EmailMessage(Guid id, Guid? senderId, Guid contextId, string subject, string? text, string senderEmailAddress) : this()
{ {
Id = id;
SenderId = senderId;
ContextId = contextId;
Subject = subject;
Text = text;
SenderEmailAddress = senderEmailAddress;
} }
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
public Guid Id { get; set; }
public Guid ContextId { get; set; }
public Guid? SenderId { get; set; }
public virtual List<EmailRecipient> Recipients { get; set; } = [];
[MaxLength(150)]
public string SenderEmailAddress { get; set; }
[MaxLength(100)]
public string Subject { get; set; }
public string? Text { get; set; }
public DateTime Created { get; set; }
public DateTime Modified { get; set; }
} }

View File

@ -1,17 +1,31 @@
using System.ComponentModel.DataAnnotations.Schema; using AyCode.Interfaces.Entities;
using AyCode.Entities.Messages; using AyCode.Interfaces.TimeStampInfo;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace TIAM.Entities.Emails; namespace TIAM.Entities.Emails;
//Update efcore, aspnetcore to 8.0.1; Implement EmailMessage, EmailRecipient; refactoring, improvments, fixes, etc... //Update efcore, aspnetcore to 8.0.1; Implement EmailMessage, EmailRecipient; refactoring, improvments, fixes, etc...
[Table(nameof(EmailRecipient))] public class EmailRecipient : IEntityGuid, ITimeStampInfo, IEmailMessageRelation
public class EmailRecipient : AcEmailRecipient<EmailMessage> //IEntityGuid, ITimeStampInfo, IEmailMessageRelation, IEmailAddress
{ {
public EmailRecipient() public EmailRecipient()
{ {
} }
public EmailRecipient(Guid id, Guid recipientId, Guid emailMessageId, string emailAddress) : base(id, recipientId, emailMessageId, emailAddress) public EmailRecipient(Guid id, Guid recipientId, Guid emailMessageId) : this()
{ {
Id = id;
RecipientId = recipientId;
EmailMessageId = emailMessageId;
} }
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
public Guid Id { get; set; }
public Guid RecipientId { get; set; }
public Guid EmailMessageId { get; set; }
public virtual EmailMessage EmailMessage { get; set; }
public DateTime Created { get; set; }
public DateTime Modified { get; set; }
} }

View File

@ -1,8 +0,0 @@
using AyCode.Interfaces.Messages;
namespace TIAM.Entities.Emails;
public interface IEmailMessage : IAcEmailMessage<IEmailRecipientBase>, IEmailMessageBase
{
}

View File

@ -1,8 +0,0 @@
using AyCode.Interfaces.Messages;
namespace TIAM.Entities.Emails;
public interface IEmailMessageBase : IAcEmailMessageBase
{
}

View File

@ -1,6 +1,9 @@
using AyCode.Interfaces.Messages; namespace TIAM.Entities.Emails;
namespace TIAM.Entities.Emails; public interface IEmailMessageForeignKey<T>
{
public T EmailMessageId { get; set; }
}
public interface IEmailMessageForeignKey : IAcEmailMessageForeignKey public interface IEmailMessageForeignKey : IEmailMessageForeignKey<Guid>
{ } { }

View File

@ -1,9 +1,6 @@
using AyCode.Interfaces.Messages; namespace TIAM.Entities.Emails;
namespace TIAM.Entities.Emails; public interface IEmailMessageRelation : IEmailMessageForeignKey
{
public interface IEmailMessageRelation : IEmailMessageRelation<EmailMessage> public EmailMessage EmailMessage{ get; set; }
{ } }
public interface IEmailMessageRelation<TEmailMessage> : IAcEmailMessageRelation<TEmailMessage>, IEmailMessageForeignKey where TEmailMessage : IAcEmailMessageBase
{ }

View File

@ -1,8 +0,0 @@
using AyCode.Interfaces.Messages;
namespace TIAM.Entities.Emails;
public interface IEmailRecipient : IAcEmailRecipient<IEmailMessage>, IEmailRecipientBase
{
}

View File

@ -1,8 +0,0 @@
using AyCode.Interfaces.Messages;
namespace TIAM.Entities.Emails;
public interface IEmailRecipientBase : IAcEmailRecipientBase
{
}

View File

@ -1,11 +1,6 @@
using AyCode.Interfaces.Messages; namespace TIAM.Entities.Emails;
namespace TIAM.Entities.Emails; public interface IEmailRecipientsRelation
public interface IEmailRecipientsRelation : IEmailRecipientsRelation<EmailRecipient>
{
}
public interface IEmailRecipientsRelation<TEmailRecipient> : IAcEmailRecipientsRelation<TEmailRecipient> where TEmailRecipient : IAcEmailRecipientBase
{ {
public List<EmailRecipient> Recipients { get; set; }
} }

View File

@ -1,12 +0,0 @@
using AyCode.Interfaces.Messages;
namespace TIAM.Entities.Emails;
public interface IMessageSenderService : IMessageSenderService<EmailMessage, EmailRecipient>
{}
public interface IMessageSenderService<TEmailMessage, TEmailRecipient> : IAcMessageSenderService<TEmailMessage, TEmailRecipient>
where TEmailMessage : IAcEmailMessage<TEmailRecipient>
where TEmailRecipient : IAcEmailRecipientBase
{
}

View File

@ -1,4 +1,9 @@
using AyCode.Entities.Groups; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Entities.Groups;
namespace TIAM.Entities.Groups namespace TIAM.Entities.Groups
{ {

View File

@ -1,5 +1,9 @@
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using AyCode.Entities.Groups; using AyCode.Entities.Groups;
using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo;
using TIAM.Entities.Groups;
namespace TIAM.Entities.Permissions; namespace TIAM.Entities.Permissions;

View File

@ -1,19 +0,0 @@
using AyCode.Interfaces.Entities;
using TIAM.Core.Enums;
using TIAM.Entities.Profiles;
namespace TIAM.Entities.Products;
interface IProductBase : IEntityGuid, IProfileRelation<Profile>
{
ProductType ProductType { get; set; }
//public Guid? UserMediaId { get; set; }
Guid ProfileId { get; set; }
Profile Profile { get; set; }
string Name { get; set; }
string Description { get; set; }
float Price { get; set; }
string? JsonDetails { get; set; }
}

View File

@ -1,9 +1,9 @@
namespace TIAM.Entities.Products; namespace TIAM.Entities.Products;
public interface IProductForeignKey<T> public interface IEmailMessageForeignKey<T>
{ {
public T ProductId { get; set; } public T ProductId { get; set; }
} }
public interface IProductForeignKey : IProductForeignKey<Guid> public interface IProductForeignKey : IEmailMessageForeignKey<Guid>
{ } { }

View File

@ -1,9 +1,11 @@
using TIAM.Entities.Users; using AyCode.Interfaces.ServiceProviders;
using AyCode.Interfaces.Users;
using TIAM.Entities.Users;
namespace TIAM.Entities.Products; namespace TIAM.Entities.Products;
public interface IProductsRelation public interface IProductsRelation
{ {
//public List<UserProductMapping> UserProductMappings { get; set; } public List<UserProductMapping> UserProductMappings { get; set; }
public List<Product> Products { get; set; } public List<Product> Products { get; set; }
} }

View File

@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using AyCode.Core.Extensions; using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo;
using TIAM.Core.Enums; using TIAM.Core.Enums;
using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users; using TIAM.Entities.Users;
@ -14,7 +14,7 @@ public class Product : ProductBase
[Required] [Required]
public Guid ServiceProviderId { get; set; } public Guid ServiceProviderId { get; set; }
public virtual Company ServiceProvider { get; set; } public virtual TiamServiceProvider ServiceProvider { get; set; }
public virtual List<User> Users { get; } = new(); public virtual List<User> Users { get; } = new();
public virtual List<UserProductMapping> UserProductMappings { get; } = new(); public virtual List<UserProductMapping> UserProductMappings { get; } = new();
@ -26,29 +26,10 @@ public class Product : ProductBase
{ {
ServiceProviderId = serviceProviderId; ServiceProviderId = serviceProviderId;
} }
public Product(Guid ownerId, Company serviceProvider, ProductType productType, string name, string description, float price, string jsonDetails) : this(Guid.NewGuid(), ownerId, serviceProvider, productType, name, description, price, jsonDetails) { } public Product(Guid ownerId, TiamServiceProvider serviceProvider, ProductType productType, string name, string description, float price, string jsonDetails) : this(Guid.NewGuid(), ownerId, serviceProvider, productType, name, description, price, jsonDetails) { }
public Product(Guid id, Guid serviceProviderId, Company serviceProvider, ProductType productType, string name, string description, float price, string jsonDetails) : base(id, productType, name, description, price, jsonDetails) public Product(Guid id, Guid serviceProviderId, TiamServiceProvider serviceProvider, ProductType productType, string name, string description, float price, string jsonDetails) : base(id, productType, name, description, price, jsonDetails)
{ {
ServiceProviderId = serviceProviderId; ServiceProviderId = serviceProviderId;
ServiceProvider = serviceProvider; ServiceProvider = serviceProvider;
} }
public void SetProfile(Profile profile)
{
if (profile.Id.IsNullOrEmpty()) profile.Id = Guid.NewGuid();
Profile = profile;
ProfileId = profile.Id;
}
public bool HasUser(Guid userId)
=> UserProductMappings.Any(x => x.UserId == userId);
public void AddUser(Guid userId, int permissions)
{
if (UserProductMappings.Any(x => x.UserId == userId))
return;
UserProductMappings.Add(new UserProductMapping(Guid.NewGuid(), userId, Id) { Permissions = permissions });
}
} }

View File

@ -1,13 +1,15 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using AyCode.Interfaces.Entities;
using AyCode.Interfaces.Profiles;
using AyCode.Interfaces.TimeStampInfo; using AyCode.Interfaces.TimeStampInfo;
using Newtonsoft.Json;
using TIAM.Core.Enums; using TIAM.Core.Enums;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
namespace TIAM.Entities.Products; namespace TIAM.Entities.Products;
public abstract class ProductBase : IProductBase, ITimeStampInfo
public abstract class ProductBase : IEntityGuid, ITimeStampInfo, IProfileRelation
{ {
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)] [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
public Guid Id { get; set; } public Guid Id { get; set; }
@ -24,10 +26,6 @@ public abstract class ProductBase : IProductBase, ITimeStampInfo
public string Name { get; set; } public string Name { get; set; }
public string Description { get; set; } public string Description { get; set; }
public float Price { get; set; } public float Price { get; set; }
[NotMapped]
[JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string? JsonDetails { get; set; } public string? JsonDetails { get; set; }
public DateTime Created { get; set; } public DateTime Created { get; set; }

View File

@ -3,7 +3,7 @@ using TIAM.Entities.Addresses;
namespace TIAM.Entities.Profiles; namespace TIAM.Entities.Profiles;
public interface IProfile<TAddress> : IAcProfile<TAddress>, IProfileDto<TAddress> where TAddress : class, IAddress public interface IProfile : IAcProfile<Address>, IProfileDto
{ {
} }

View File

@ -1,13 +1,8 @@
using AyCode.Interfaces.Profiles.Dtos; using AyCode.Interfaces.Profiles.Dtos;
using TIAM.Entities.Addresses;
namespace TIAM.Entities.Profiles; namespace TIAM.Entities.Profiles;
public interface IProfileDto : IAcProfileDtoBase public interface IProfileDto : IAcProfileDtoBase
{ {
}
public interface IProfileDto<TAddress> : IProfileDto, IAcProfileDtoBase<TAddress> where TAddress : class, IAddressDto
{
} }

View File

@ -2,6 +2,6 @@
namespace TIAM.Entities.Profiles; namespace TIAM.Entities.Profiles;
public interface IProfileRelation<TProfile> : IAcProfileRelation<TProfile>, IProfileForeignKey where TProfile : class, IProfileDto public interface IProfileRelation : IAcProfileRelation<Profile>, IProfileForeignKey
{ {
} }

View File

@ -1,18 +1,9 @@
using AyCode.Entities.Profiles; using AyCode.Entities.Profiles;
using System.ComponentModel.DataAnnotations.Schema;
using TIAM.Entities.Addresses; using TIAM.Entities.Addresses;
namespace TIAM.Entities.Profiles; namespace TIAM.Entities.Profiles;
[Table(nameof(Profile))] public class Profile : AcProfile<Address>, IProfile
public class Profile : AcProfile<Address>, IProfile<Address>
{ {
public Profile() : base()
{ }
public Profile(Guid id) : base(id)
{ }
public Profile(Guid id, string name) : base(id, name)
{ }
} }

View File

@ -1,34 +0,0 @@
using System.ComponentModel.DataAnnotations.Schema;
using AyCode.Entities.ServiceProviders;
using TIAM.Entities.Addresses;
using TIAM.Entities.Products;
using TIAM.Entities.Profiles;
using TIAM.Entities.Users;
namespace TIAM.Entities.ServiceProviders;
[Table("ServiceProviders")]
public class Company : AcCompany<User, UserToCompany, Profile, Address>, ICompany, IProductsRelation, IProfileRelation<Profile>
{
public virtual List<Product> Products { get; set; } = new();
public Company()
{
}
public Company(string name, Guid? ownerId) : this(Guid.NewGuid(), name, ownerId)
{
}
public Company(Guid id, string name, Guid? ownerId) : this(id, name, ownerId, Guid.NewGuid())
{
}
public Company(Guid id, string name, Guid? ownerId, double commissionPercent) : this(id, name, ownerId, Guid.NewGuid())
{
CommissionPercent = commissionPercent;
}
public Company(Guid id, string name, Guid? ownerId, Guid affiliateId) : base(id, name, ownerId, affiliateId)
{ }
}

Some files were not shown because too many files have changed in this diff Show More