From f1ebd36f929d9b821d86a587f4a6b4af616a8879 Mon Sep 17 00:00:00 2001 From: Kimia Kabiri <126855522+K-Kabiri@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:48:23 +0330 Subject: [PATCH] Test admin services (#79) * feat(Test-Repository): Add RoleRepositoryTests class. * feat(Test-Repository): Add UserRepositoryTests class. * feat(Admin-Service): Add AdminRegisterServiceTests and AdminServiceTests classes. * fix(Test-AdminService): fix bugs and edit some methods in AdminServiceTests and AdminRegisterServiceTests classes. * fix(Test-AdminService): edit AdminServiceTests class. * fix(Test-Repository): comment repository test classes. * fix(Test-Repository): edit role and user repositories. --- .../AnalysisData.sln.DotSettings.user | 47 ++ AnalysisData/AnalysisData/AnalysisData.csproj | 9 +- .../AnalysisData.csproj.DotSettings | 2 +- AnalysisData/AnalysisData/Authorization.cs | 1 - AnalysisData/AnalysisData/ConfigService.cs | 76 ++- .../AnalysisData/Data/ApplicationDbContext.cs | 15 +- .../GraphException/CategoryAlreadyExist.cs | 2 +- .../CategoryResultNotFoundException.cs | 2 +- .../GraphException/EdgeNotFoundException.cs | 2 +- .../GraphException/FileExistenceException.cs | 2 +- .../HeaderIdNotFoundInNodeFile.cs | 2 +- .../GraphException/NoFileUploadedException.cs | 2 +- .../GraphException/NodeNotFoundException.cs | 2 +- .../NodeNotFoundInEntityeEdgeException.cs | 2 +- .../UserException/AdminExistenceException.cs | 2 +- .../DuplicateRoleExistException.cs | 2 +- .../UserException/DuplicateUserException.cs | 2 +- .../UserException/GuidNotCorrectFormat.cs | 2 +- .../InvalidEmailFormatException.cs | 2 +- .../UserException/InvalidPasswordException.cs | 4 +- .../InvalidPasswordFormatException.cs | 2 +- .../InvalidPhoneNumberFormatException.cs | 2 +- .../PasswordMismatchException.cs | 2 +- .../UserException/RoleNotFoundException.cs | 2 +- .../TokenNotFoundInCookieException.cs | 2 +- .../UserException/UserNotFoundException.cs | 4 +- .../Graph/Controllers/CategoriesController.cs | 6 +- .../Graph/Controllers/FileAccessController.cs | 9 +- .../Graph/Controllers/FileController.cs | 11 +- .../Graph/Controllers/GraphEavController.cs | 11 +- .../Graph/Dto/AccessFileToUserDto.cs | 2 +- .../Graph/Dto/CategoryDto/CategoryDto.cs | 2 +- .../Graph/Dto/CategoryDto/NewCategoryDto.cs | 2 +- .../Dto/CategoryDto/PaginationCategoryDto.cs | 4 +- .../AnalysisData/Graph/Dto/EdgeDto/EdgeDto.cs | 2 +- .../Graph/Dto/EdgeDto/EdgeUploadDto.cs | 2 +- .../AnalysisData/Graph/Dto/FileEntityDto.cs | 2 +- .../AnalysisData/Graph/Dto/NodeDto/NodeDto.cs | 2 +- .../Graph/Dto/NodeDto/NodeUploadDto.cs | 3 +- .../Graph/Dto/NodeDto/PaginatedNodeListDto.cs | 2 +- .../Graph/Dto/NodeDto/PaginationNodeDto.cs | 2 +- .../Graph/Dto/PaginatedFileDto.cs | 2 +- .../AnalysisData/Graph/Dto/UserAccessDto.cs | 2 +- .../Graph/Dto/WhoAccessThisFileDto.cs | 2 +- .../Graph/Model/Category/Category.cs | 2 +- .../Graph/Model/Edge/AttributeEdge.cs | 2 +- .../Graph/Model/Edge/EntityEdge.cs | 3 +- .../Graph/Model/Edge/ValueEdge.cs | 2 +- .../Graph/Model/File/FileEntity.cs | 8 +- .../AnalysisData/Graph/Model/File/UserFile.cs | 5 +- .../Graph/Model/Node/AttributeNode.cs | 2 +- .../Graph/Model/Node/EntityNode.cs | 3 +- .../Graph/Model/Node/ValueNode.cs | 2 +- .../Abstraction/ICategoryRepository.cs | 5 +- .../CategoryRepository/CategoryRepository.cs | 7 +- .../Abstraction/IAttributeEdgeRepository.cs | 4 +- .../Abstraction/IEntityEdgeRepository.cs | 4 +- .../Abstraction/IValueEdgeRepository.cs | 4 +- .../EdgeRepository/AttributeEdgeRepository.cs | 6 +- .../EdgeRepository/EntityEdgeRepository.cs | 6 +- .../EdgeRepository/ValueEdgeRepository.cs | 6 +- .../Abstraction/IFileUploadedRepository.cs | 4 +- .../FileUploadedRepository.cs | 6 +- .../GraphEdgeRepository.cs | 4 +- .../IGraphEdgeRepository.cs | 4 +- .../GraphNodeRepository.cs | 8 +- .../IGraphNodeRepository.cs | 4 +- .../Abstraction/IAttributeNodeRepository.cs | 4 +- .../Abstraction/IEntityNodeRepository.cs | 4 +- .../Abstraction/IValueNodeRepository.cs | 4 +- .../NodeRepository/AttributeNodeRepository.cs | 6 +- .../NodeRepository/EntityNodeRepository.cs | 6 +- .../NodeRepository/ValueNodeRepository.cs | 6 +- .../Abstraction/IUserFileRepository.cs | 4 +- .../UserFileRepository/UserFileRepository.cs | 7 +- .../Abstraction/ICategoryService.cs | 6 +- .../CategoryService/CategoryService.cs | 16 +- .../AccessManagementService.cs | 7 +- .../IAccessManagementService.cs | 2 +- .../FilePermissionService.cs | 16 +- .../IFilePermissionService.cs | 6 +- .../Abstraction/IUploadFileService.cs | 2 +- .../FileUploadService/UploadFileService.cs | 9 +- .../AllNodesData/INodePaginationService.cs | 5 +- .../AllNodesData/NodePaginationService.cs | 17 +- .../NodeAndEdgeInfo/INodeAndEdgeInfo.cs | 2 +- .../NodeAndEdgeInfo/NodeAndEdgeInfo.cs | 7 +- .../Relationship/GraphRelationService.cs | 15 +- .../Relationship/IGraphRelationService.cs | 5 +- .../Search/GraphSearchService.cs | 8 +- .../Search/IGraphSearchService.cs | 4 +- .../Abstraction/ICsvReaderService.cs | 2 +- .../Abstraction/IEdgeRecordProcessor.cs | 9 + .../Abstraction/IEdgeToDbService.cs | 2 +- .../Abstraction/IEntityEdgeRecordProcessor.cs | 2 +- .../Abstraction/IFromToProcessor.cs | 2 +- .../Abstraction/IHeaderProcessor.cs | 2 +- .../Abstraction/INodeRecordProcessor.cs | 4 +- .../Abstraction/INodeToDbService.cs | 2 +- .../Abstraction/IValueEdgeProcessor.cs | 2 +- .../Abstraction/IValueNodeProcessor.cs | 2 +- .../ServiceBusiness/CsvReaderService.cs | 5 +- .../ServiceBusiness/EdgeRecordProcessor.cs | 35 ++ .../ServiceBusiness/EdgeToDbService.cs | 7 +- .../EntityEdgeRecordProcessor.cs | 9 +- .../EntityNodeRecordProcessor.cs | 9 +- .../ServiceBusiness/FromToProcessor.cs | 8 +- .../ServiceBusiness/HeaderProcessor.cs | 8 +- .../ServiceBusiness/NodeRecordProcessor.cs | 6 + .../ServiceBusiness/NodeToDbService.cs | 7 +- .../ServiceBusiness/ValueEdgeProcessor.cs | 4 +- .../ServiceBusiness/ValueNodeProcessor.cs | 6 +- .../20240903222320_initial.Designer.cs | 458 -------------- .../Migrations/20240903222320_initial.cs | 361 ----------- .../ApplicationDbContextModelSnapshot.cs | 455 -------------- AnalysisData/AnalysisData/Program.cs | 3 +- .../User/Controllers/AdminController.cs | 9 +- .../User/Controllers/RoleController.cs | 7 +- .../User/Controllers/UserController.cs | 15 +- .../User/CookieService/CookieService.cs | 4 +- .../abstractions/ICookieService.cs | 2 +- .../User/JwtService/JwtService.cs | 10 +- .../JwtService/abstractions/IJwtService.cs | 2 +- .../MiddleWare/ExceptionHandlingMiddleware.cs | 3 +- .../User/MiddleWare/JwtMiddleware.cs | 2 +- .../AnalysisData/User/Model/RegexPatterns.cs | 2 +- AnalysisData/AnalysisData/User/Model/Role.cs | 4 +- AnalysisData/AnalysisData/User/Model/User.cs | 4 +- .../Abstraction/IRoleRepository.cs | 4 +- .../RoleRepository/RoleRepository.cs | 6 +- .../Abstraction/IUserRepository.cs | 18 +- .../UserRepository/UserRepository.cs | 19 +- .../Abstraction/IAdminRegisterService.cs | 4 +- .../AdminService/Abstraction/IAdminService.cs | 8 +- .../AdminService/AdminRegisterService.cs | 69 +- .../Services/AdminService/AdminService.cs | 41 +- .../Abstraction/IPermissionService.cs | 2 +- .../PermissionService.cs | 8 +- .../Abstraction/IRoleManagementService.cs | 4 +- .../RoleService/RoleManagementService.cs | 16 +- .../Abstraction/IS3FileStorageService.cs | 2 +- .../S3FileStorageService.cs | 3 +- .../Abstraction/IPasswordHasher.cs | 2 +- .../SecurityPasswordService/PasswordHasher.cs | 4 +- .../Abstraction/IUploadImageService.cs | 2 +- .../UserService/Abstraction/IUserService.cs | 11 +- .../UserService/UploadImageService.cs | 10 +- .../User/Services/UserService/UserService.cs | 30 +- .../Abstraction/IValidationService.cs | 2 +- .../ValidationService/ValidationService.cs | 8 +- .../UserDto/PasswordDto/NewPasswordDto.cs | 2 +- .../UserDto/PasswordDto/ResetPasswordDto.cs | 2 +- .../User/UserDto/RoleDto/AddRoleDto.cs | 2 +- .../User/UserDto/RoleDto/RolePaginationDto.cs | 2 +- .../UserDto/UserDto/GetUserInformationDto.cs | 2 +- .../User/UserDto/UserDto/UpdateAdminDto.cs | 2 +- .../User/UserDto/UserDto/UpdateUserDto.cs | 2 +- .../User/UserDto/UserDto/UserLoginDto.cs | 2 +- .../User/UserDto/UserDto/UserPaginationDto.cs | 2 +- .../User/UserDto/UserDto/UserRegisterDto.cs | 2 +- .../RoleRepository/RoleRepositoryTests.cs | 89 --- .../UserRepository/UserRepositoryTests.cs | 115 ---- AnalysisData/TestProject/TestProject.csproj | 7 + .../RoleRepository/RoleRepositoryTests.cs | 254 ++++++++ .../UserRepository/UserRepositoryTests.cs | 593 ++++++++++++++++++ .../AdminService/AdminRegisterServiceTests.cs | 157 +++++ .../AdminService/AdminServiceTests.cs | 224 +++++++ 167 files changed, 1794 insertions(+), 1943 deletions(-) create mode 100644 AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEdgeRecordProcessor.cs create mode 100644 AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EdgeRecordProcessor.cs create mode 100644 AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/NodeRecordProcessor.cs delete mode 100644 AnalysisData/AnalysisData/Migrations/20240903222320_initial.Designer.cs delete mode 100644 AnalysisData/AnalysisData/Migrations/20240903222320_initial.cs delete mode 100644 AnalysisData/AnalysisData/Migrations/ApplicationDbContextModelSnapshot.cs rename AnalysisData/AnalysisData/User/Services/{PemissionService => PermissionService}/Abstraction/IPermissionService.cs (68%) rename AnalysisData/AnalysisData/User/Services/{PemissionService => PermissionService}/PermissionService.cs (91%) delete mode 100644 AnalysisData/TestProject/Repository/RoleRepository/RoleRepositoryTests.cs delete mode 100644 AnalysisData/TestProject/Repository/UserRepository/UserRepositoryTests.cs create mode 100644 AnalysisData/TestProject/User/Repository/RoleRepository/RoleRepositoryTests.cs create mode 100644 AnalysisData/TestProject/User/Repository/UserRepository/UserRepositoryTests.cs create mode 100644 AnalysisData/TestProject/User/Services/AdminService/AdminRegisterServiceTests.cs create mode 100644 AnalysisData/TestProject/User/Services/AdminService/AdminServiceTests.cs diff --git a/AnalysisData/AnalysisData.sln.DotSettings.user b/AnalysisData/AnalysisData.sln.DotSettings.user index 42093ae..7f9b11c 100644 --- a/AnalysisData/AnalysisData.sln.DotSettings.user +++ b/AnalysisData/AnalysisData.sln.DotSettings.user @@ -1,4 +1,5 @@  + C:\Users\kimia\AppData\Local\JetBrains\Rider2024.1\resharper-host\temp\Rider\vAny\CoverageData\_AnalysisData.-35481945\Snapshot\snapshot.utdcvr @@ -7,6 +8,30 @@ <TestAncestor> <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.Repository.RoleRepository.RoleRepositoryTests</TestId> </TestAncestor> +</SessionState> + <SessionState ContinuousTestingMode="0" Name="GetUserByUsernameAsync_ShouldReturnsUserWithInputUsername_WhenUserExists" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <TestAncestor> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetUserByEmailAsync_ShouldReturnsNull_WhenUserWithInputEmailDoesNotExist</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetUserByIdAsync_ShouldReturnsUserWithInputId_WhenUserWithInputIdExists</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetUserByIdAsync_ShouldReturnsNull_WhenUserWithInputIdDoesNotExist</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetAllUserPaginationAsync_ShouldReturnPaginatedResults_WhenUsersExist</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetAllUserPaginationAsync_ShouldReturnAllUsers_WhenPageZeroAndLimitIsGreaterThanNumberOfExistingUsers</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetAllUserPaginationAsync_ShouldReturnsEmptyList_WhenPageIsOutOfRange</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetUsersCountAsync_ShouldReturnsCountsOfUsers_Whenever</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.DeleteUserAsync_ShouldReturnsDeleteUserWithInputUserId_WhenUserWithInputUserIdIsExist</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.DeleteUserAsync_ShouldReturnsNull_WhenUserWithInputUserIdIsDoesNotExist</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.AddUserAsync_ShouldAddsUserToDatabase</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.UpdateUserAsync_ShouldReturnTrue_AndUpdateUser_WhenUserExists</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetTopUsersByUsernameSearchAsync_ShouldReturnEmptyList_WhenNoUsersMatch</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.RoleRepository.RoleRepositoryTests</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetUserByUsernameAsync_ShouldReturnsUserWithInputUsername_WhenUserWithInputUsernameExists</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminServiceTests.UpdateUserInformationByAdminAsync_ShouldUpdateUser_WhenDataIsValid</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminServiceTests.DeleteUserAsync_ShouldReturnTrue_WhenUserExists</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::AdminServiceTests</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminRegisterServiceTests</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminServiceTests</TestId> + </TestAncestor> </SessionState> <SessionState ContinuousTestingMode="0" Name="GetRole_ShouldReturnsRole_WhenRoleExists #3" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <Project Location="C:\Users\Mahdi\Desktop\New folder (2)\Summer1403-Project-Group03-Backend\AnalysisData\TestProject" Presentation="&lt;TestProject&gt;" /> @@ -37,11 +62,29 @@ <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.Repository.UserRepository.UserRepositoryTests</TestId> <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.Repository.RoleRepository.RoleRepositoryTests.DeleteRole_ShouldReturnsFalse_WhenRoleDoesNotExist</TestId> </TestAncestor> +</SessionState> + <SessionState ContinuousTestingMode="0" IsActive="True" Name="CheckExistenceOfRole_ShouldNotThrowException_WhenRoleExists" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <TestAncestor> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminServiceTests</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminRegisterServiceTests.RegisterByAdminAsync_ShouldThrowDuplicateUserException_WhenUserAlreadyExists</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminRegisterServiceTests.CheckExistenceRole_ShouldThrowRoleNotFoundException_WhenRoleDoesNotExist</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminRegisterServiceTests.ValidateUserInformation_ShouldThrowDuplicateUserException_WhenUserAlreadyExists</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminRegisterServiceTests</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.RoleRepository.RoleRepositoryTests</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetUserByUsernameAsync_ShouldReturnsUserWithInputUsername_WhenUserWithInputUsernameExists</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests</TestId> + </TestAncestor> </SessionState> <SessionState ContinuousTestingMode="0" Name="AddRole_ShouldAddsRoleToDatabase_Whenever" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <TestAncestor> <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.Repository.RoleRepository.RoleRepositoryTests.AddRole_ShouldAddsRoleToDatabase_Whenever</TestId> </TestAncestor> +</SessionState> + <SessionState ContinuousTestingMode="0" Name="DeleteRole_ShouldRemovesRoleAndReturnsTrue_WhenRoleExists #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <TestAncestor> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.RoleRepository.RoleRepositoryTests</TestId> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetUserByUsernameAsync_ShouldReturnsUserWithInputUsername_WhenUserExists</TestId> + </TestAncestor> </SessionState> <SessionState ContinuousTestingMode="0" Name="All tests from &lt;TestProject&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <TestAncestor> @@ -59,6 +102,10 @@ <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.RoleRepository.RoleRepositoryTests</TestId> <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminRegisterServiceTests</TestId> <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Services.AdminService.AdminServiceTests</TestId> + </TestAncestor> + <SessionState ContinuousTestingMode="0" Name="All tests from &lt;TestProject&gt; #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <TestAncestor> + <TestId>xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.RoleRepository.RoleRepositoryTests.GetRoleByIdAsync_ReturnsRole_WhenRoleExists</TestId> </TestAncestor> </SessionState> True diff --git a/AnalysisData/AnalysisData/AnalysisData.csproj b/AnalysisData/AnalysisData/AnalysisData.csproj index d58f1a0..d72f13a 100644 --- a/AnalysisData/AnalysisData/AnalysisData.csproj +++ b/AnalysisData/AnalysisData/AnalysisData.csproj @@ -22,6 +22,7 @@ + @@ -42,10 +43,6 @@ - - - - <_ContentIncludedByDefault Remove="out\web.config" /> <_ContentIncludedByDefault Remove="out\AnalysisData.runtimeconfig.json" /> @@ -53,4 +50,8 @@ <_ContentIncludedByDefault Remove="out\appsettings.json" /> + + + + diff --git a/AnalysisData/AnalysisData/AnalysisData.csproj.DotSettings b/AnalysisData/AnalysisData/AnalysisData.csproj.DotSettings index e33bdfd..ad157b1 100644 --- a/AnalysisData/AnalysisData/AnalysisData.csproj.DotSettings +++ b/AnalysisData/AnalysisData/AnalysisData.csproj.DotSettings @@ -1,2 +1,2 @@  - True \ No newline at end of file + False \ No newline at end of file diff --git a/AnalysisData/AnalysisData/Authorization.cs b/AnalysisData/AnalysisData/Authorization.cs index 9ee8049..8c4f2bb 100644 --- a/AnalysisData/AnalysisData/Authorization.cs +++ b/AnalysisData/AnalysisData/Authorization.cs @@ -1,5 +1,4 @@ using System.Text; -using AnalysisData.Repository.RoleRepository.Abstraction; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; diff --git a/AnalysisData/AnalysisData/ConfigService.cs b/AnalysisData/AnalysisData/ConfigService.cs index ca8ff65..9229eeb 100644 --- a/AnalysisData/AnalysisData/ConfigService.cs +++ b/AnalysisData/AnalysisData/ConfigService.cs @@ -1,33 +1,49 @@ -using AnalysisData.CookieService.abstractions; -using AnalysisData.EAV.Repository; -using AnalysisData.EAV.Repository.Abstraction; -using AnalysisData.EAV.Repository.CategoryRepository; -using AnalysisData.EAV.Repository.CategoryRepository.asbtraction; -using AnalysisData.EAV.Repository.EdgeRepository; -using AnalysisData.EAV.Repository.EdgeRepository.Abstraction; -using AnalysisData.EAV.Repository.FileUploadedRepository; -using AnalysisData.EAV.Repository.NodeRepository; -using AnalysisData.EAV.Repository.NodeRepository.Abstraction; -using AnalysisData.EAV.Service; -using AnalysisData.EAV.Service.Abstraction; -using AnalysisData.EAV.Service.Business; -using AnalysisData.EAV.Service.Business.Abstraction; -using AnalysisData.EAV.Service.GraphServices.NodeAndEdgeServices; -using AnalysisData.EAV.Service.GraphServices.Relationship; -using AnalysisData.EAV.Service.GraphSevices; using AnalysisData.Graph.Service.ServiceBusiness; using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; -using AnalysisData.JwtService.abstractions; -using AnalysisData.Repository.RoleRepository; -using AnalysisData.Repository.RoleRepository.Abstraction; -using AnalysisData.Repository.UserRepository; -using AnalysisData.Repository.UserRepository.Abstraction; -using AnalysisData.Services; -using AnalysisData.Services.Abstraction; -using AnalysisData.Services.S3FileStorageService; -using AnalysisData.Services.SecurityPasswordService; -using AnalysisData.Services.SecurityPasswordService.Abstraction; -using Microsoft.AspNetCore.Identity; +using AnalysisData.Graph.Repository.CategoryRepository; +using AnalysisData.Graph.Repository.CategoryRepository.Abstraction; +using AnalysisData.Graph.Repository.EdgeRepository; +using AnalysisData.Graph.Repository.EdgeRepository.Abstraction; +using AnalysisData.Graph.Repository.FileUploadedRepository; +using AnalysisData.Graph.Repository.FileUploadedRepository.Abstraction; +using AnalysisData.Graph.Repository.GraphEdgeRepository; +using AnalysisData.Graph.Repository.GraphNodeRepository; +using AnalysisData.Graph.Repository.NodeRepository; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; +using AnalysisData.Graph.Repository.UserFileRepository; +using AnalysisData.Graph.Repository.UserFileRepository.Abstraction; +using AnalysisData.Graph.Service.CategoryService; +using AnalysisData.Graph.Service.CategoryService.Abstraction; +using AnalysisData.Graph.Service.FilePermissionService; +using AnalysisData.Graph.Service.FilePermissionService.AccessMangement; +using AnalysisData.Graph.Service.FileUploadService; +using AnalysisData.Graph.Service.FileUploadService.Abstraction; +using AnalysisData.Graph.Service.GraphServices.AllNodesData; +using AnalysisData.Graph.Service.GraphServices.NodeAndEdgeInfo; +using AnalysisData.Graph.Service.GraphServices.Relationship; +using AnalysisData.Graph.Service.GraphServices.Search; +using AnalysisData.User.CookieService; +using AnalysisData.User.CookieService.abstractions; +using AnalysisData.User.JwtService; +using AnalysisData.User.JwtService.abstractions; +using AnalysisData.User.Repository.RoleRepository; +using AnalysisData.User.Repository.RoleRepository.Abstraction; +using AnalysisData.User.Repository.UserRepository; +using AnalysisData.User.Repository.UserRepository.Abstraction; +using AnalysisData.User.Services.AdminService; +using AnalysisData.User.Services.AdminService.Abstraction; +using AnalysisData.User.Services.PermissionService; +using AnalysisData.User.Services.PermissionService.Abstraction; +using AnalysisData.User.Services.RoleService; +using AnalysisData.User.Services.RoleService.Abstraction; +using AnalysisData.User.Services.S3FileStorageService; +using AnalysisData.User.Services.S3FileStorageService.Abstraction; +using AnalysisData.User.Services.SecurityPasswordService; +using AnalysisData.User.Services.SecurityPasswordService.Abstraction; +using AnalysisData.User.Services.UserService; +using AnalysisData.User.Services.UserService.Abstraction; +using AnalysisData.User.Services.ValidationService; +using AnalysisData.User.Services.ValidationService.Abstraction; namespace AnalysisData; @@ -54,8 +70,8 @@ public static IServiceCollection AddRepositories(this IServiceCollection service public static IServiceCollection AddServices(this IServiceCollection services) { services.AddScoped(); - services.AddScoped(); - services.AddScoped(); + services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/AnalysisData/AnalysisData/Data/ApplicationDbContext.cs b/AnalysisData/AnalysisData/Data/ApplicationDbContext.cs index 7f85261..64fe774 100644 --- a/AnalysisData/AnalysisData/Data/ApplicationDbContext.cs +++ b/AnalysisData/AnalysisData/Data/ApplicationDbContext.cs @@ -1,6 +1,8 @@ -using AnalysisData.EAV.Model; -using AnalysisData.Services.SecurityPasswordService.Abstraction; -using AnalysisData.UserManage.Model; +using AnalysisData.Graph.Model.Category; +using AnalysisData.Graph.Model.Edge; +using AnalysisData.Graph.Model.File; +using AnalysisData.Graph.Model.Node; +using AnalysisData.User.Model; using Microsoft.EntityFrameworkCore; namespace AnalysisData.Data; @@ -11,9 +13,8 @@ public ApplicationDbContext(DbContextOptions options) : base(options) { } - - public DbSet Users { get; set; } + public DbSet Users { get; set; } public DbSet AttributeEdges { get; set; } public DbSet AttributeNodes { get; set; } public DbSet EntityEdges { get; set; } @@ -35,9 +36,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) new Role { Id = 3, RoleName = "Data-Manager", RolePolicy = "silver" } ); - modelBuilder.Entity().HasData( + modelBuilder.Entity().HasData( - new User + new User.Model.User { Id = Guid.NewGuid(), Username = "admin", diff --git a/AnalysisData/AnalysisData/Exception/GraphException/CategoryAlreadyExist.cs b/AnalysisData/AnalysisData/Exception/GraphException/CategoryAlreadyExist.cs index 4aacdcf..ce8da45 100644 --- a/AnalysisData/AnalysisData/Exception/GraphException/CategoryAlreadyExist.cs +++ b/AnalysisData/AnalysisData/Exception/GraphException/CategoryAlreadyExist.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.GraphException; public class CategoryAlreadyExist : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/GraphException/CategoryResultNotFoundException.cs b/AnalysisData/AnalysisData/Exception/GraphException/CategoryResultNotFoundException.cs index 31b114a..5288ef9 100644 --- a/AnalysisData/AnalysisData/Exception/GraphException/CategoryResultNotFoundException.cs +++ b/AnalysisData/AnalysisData/Exception/GraphException/CategoryResultNotFoundException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.GraphException; public class CategoryResultNotFoundException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/GraphException/EdgeNotFoundException.cs b/AnalysisData/AnalysisData/Exception/GraphException/EdgeNotFoundException.cs index 98104ea..3148a21 100644 --- a/AnalysisData/AnalysisData/Exception/GraphException/EdgeNotFoundException.cs +++ b/AnalysisData/AnalysisData/Exception/GraphException/EdgeNotFoundException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.GraphException; public class EdgeNotFoundException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/GraphException/FileExistenceException.cs b/AnalysisData/AnalysisData/Exception/GraphException/FileExistenceException.cs index d1e32ee..8e75c00 100644 --- a/AnalysisData/AnalysisData/Exception/GraphException/FileExistenceException.cs +++ b/AnalysisData/AnalysisData/Exception/GraphException/FileExistenceException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.GraphException; public class FileExistenceException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/GraphException/HeaderIdNotFoundInNodeFile.cs b/AnalysisData/AnalysisData/Exception/GraphException/HeaderIdNotFoundInNodeFile.cs index 8878c92..73eaa67 100644 --- a/AnalysisData/AnalysisData/Exception/GraphException/HeaderIdNotFoundInNodeFile.cs +++ b/AnalysisData/AnalysisData/Exception/GraphException/HeaderIdNotFoundInNodeFile.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.GraphException; public class HeaderIdNotFoundInNodeFile : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/GraphException/NoFileUploadedException.cs b/AnalysisData/AnalysisData/Exception/GraphException/NoFileUploadedException.cs index b78d4ff..783dafc 100644 --- a/AnalysisData/AnalysisData/Exception/GraphException/NoFileUploadedException.cs +++ b/AnalysisData/AnalysisData/Exception/GraphException/NoFileUploadedException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.GraphException; public class NoFileUploadedException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/GraphException/NodeNotFoundException.cs b/AnalysisData/AnalysisData/Exception/GraphException/NodeNotFoundException.cs index 7977ece..3c2fca0 100644 --- a/AnalysisData/AnalysisData/Exception/GraphException/NodeNotFoundException.cs +++ b/AnalysisData/AnalysisData/Exception/GraphException/NodeNotFoundException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.GraphException; public class NodeNotFoundException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/GraphException/NodeNotFoundInEntityeEdgeException.cs b/AnalysisData/AnalysisData/Exception/GraphException/NodeNotFoundInEntityeEdgeException.cs index aa619bb..67e8ed5 100644 --- a/AnalysisData/AnalysisData/Exception/GraphException/NodeNotFoundInEntityeEdgeException.cs +++ b/AnalysisData/AnalysisData/Exception/GraphException/NodeNotFoundInEntityeEdgeException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.GraphException; public class NodeNotFoundInEntityEdgeException : ServiceException diff --git a/AnalysisData/AnalysisData/Exception/UserException/AdminExistenceException.cs b/AnalysisData/AnalysisData/Exception/UserException/AdminExistenceException.cs index 9158106..d27555b 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/AdminExistenceException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/AdminExistenceException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.UserException; public class AdminExistenceException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/DuplicateRoleExistException.cs b/AnalysisData/AnalysisData/Exception/UserException/DuplicateRoleExistException.cs index a0b53fa..b3366c5 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/DuplicateRoleExistException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/DuplicateRoleExistException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.UserException; public class DuplicateRoleExistException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/DuplicateUserException.cs b/AnalysisData/AnalysisData/Exception/UserException/DuplicateUserException.cs index e765658..80ab5ba 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/DuplicateUserException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/DuplicateUserException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.UserException; public class DuplicateUserException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/GuidNotCorrectFormat.cs b/AnalysisData/AnalysisData/Exception/UserException/GuidNotCorrectFormat.cs index ea99971..94e12d0 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/GuidNotCorrectFormat.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/GuidNotCorrectFormat.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.UserException; public class GuidNotCorrectFormat : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/InvalidEmailFormatException.cs b/AnalysisData/AnalysisData/Exception/UserException/InvalidEmailFormatException.cs index e3b22fc..c6556d0 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/InvalidEmailFormatException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/InvalidEmailFormatException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.UserException; public class InvalidEmailFormatException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/InvalidPasswordException.cs b/AnalysisData/AnalysisData/Exception/UserException/InvalidPasswordException.cs index c70b9fd..f9c3faf 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/InvalidPasswordException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/InvalidPasswordException.cs @@ -1,6 +1,4 @@ -namespace AnalysisData.Exception; - -using System; +namespace AnalysisData.Exception.UserException; public class InvalidPasswordException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/InvalidPasswordFormatException.cs b/AnalysisData/AnalysisData/Exception/UserException/InvalidPasswordFormatException.cs index 5150e64..6f292ec 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/InvalidPasswordFormatException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/InvalidPasswordFormatException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.UserException; public class InvalidPasswordFormatException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/InvalidPhoneNumberFormatException.cs b/AnalysisData/AnalysisData/Exception/UserException/InvalidPhoneNumberFormatException.cs index 10d831d..07a2adf 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/InvalidPhoneNumberFormatException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/InvalidPhoneNumberFormatException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.UserException; public class InvalidPhoneNumberFormatException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/PasswordMismatchException.cs b/AnalysisData/AnalysisData/Exception/UserException/PasswordMismatchException.cs index 756546f..d4b61d1 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/PasswordMismatchException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/PasswordMismatchException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.UserException; public class PasswordMismatchException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/RoleNotFoundException.cs b/AnalysisData/AnalysisData/Exception/UserException/RoleNotFoundException.cs index 9d51342..ce1fd15 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/RoleNotFoundException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/RoleNotFoundException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.UserException; public class RoleNotFoundException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/TokenNotFoundInCookieException.cs b/AnalysisData/AnalysisData/Exception/UserException/TokenNotFoundInCookieException.cs index 322b783..8a6cb84 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/TokenNotFoundInCookieException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/TokenNotFoundInCookieException.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Exception; +namespace AnalysisData.Exception.UserException; public class TokenNotFoundInCookieException : ServiceException { diff --git a/AnalysisData/AnalysisData/Exception/UserException/UserNotFoundException.cs b/AnalysisData/AnalysisData/Exception/UserException/UserNotFoundException.cs index d60a9fc..d8ef7db 100644 --- a/AnalysisData/AnalysisData/Exception/UserException/UserNotFoundException.cs +++ b/AnalysisData/AnalysisData/Exception/UserException/UserNotFoundException.cs @@ -1,6 +1,4 @@ -namespace AnalysisData.Exception; - -using System; +namespace AnalysisData.Exception.UserException; public class UserNotFoundException : ServiceException { diff --git a/AnalysisData/AnalysisData/Graph/Controllers/CategoriesController.cs b/AnalysisData/AnalysisData/Graph/Controllers/CategoriesController.cs index 08ecbfc..99f9a25 100644 --- a/AnalysisData/AnalysisData/Graph/Controllers/CategoriesController.cs +++ b/AnalysisData/AnalysisData/Graph/Controllers/CategoriesController.cs @@ -1,8 +1,8 @@ -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Service.Abstraction; +using AnalysisData.Graph.Dto.CategoryDto; +using AnalysisData.Graph.Service.CategoryService.Abstraction; using Microsoft.AspNetCore.Mvc; -namespace AnalysisData.EAV.Controllers; +namespace AnalysisData.Graph.Controllers; [ApiController] [Route("api/[controller]")] diff --git a/AnalysisData/AnalysisData/Graph/Controllers/FileAccessController.cs b/AnalysisData/AnalysisData/Graph/Controllers/FileAccessController.cs index b47e4a2..ea82371 100644 --- a/AnalysisData/AnalysisData/Graph/Controllers/FileAccessController.cs +++ b/AnalysisData/AnalysisData/Graph/Controllers/FileAccessController.cs @@ -1,10 +1,9 @@ -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Repository.Abstraction; -using AnalysisData.EAV.Service; -using AnalysisData.Repository.UserRepository.Abstraction; +using AnalysisData.Graph.Dto; +using AnalysisData.Graph.Repository.UserFileRepository.Abstraction; +using AnalysisData.Graph.Service.FilePermissionService; using Microsoft.AspNetCore.Mvc; -namespace AnalysisData.EAV.Controllers; +namespace AnalysisData.Graph.Controllers; [ApiController] [Route("api/[controller]")] diff --git a/AnalysisData/AnalysisData/Graph/Controllers/FileController.cs b/AnalysisData/AnalysisData/Graph/Controllers/FileController.cs index 63bcd82..a92722f 100644 --- a/AnalysisData/AnalysisData/Graph/Controllers/FileController.cs +++ b/AnalysisData/AnalysisData/Graph/Controllers/FileController.cs @@ -1,10 +1,11 @@ -using System.Security.Claims; -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Service.Abstraction; -using AnalysisData.Exception; +using AnalysisData.Exception.GraphException; +using AnalysisData.Graph.Dto.EdgeDto; +using AnalysisData.Graph.Dto.NodeDto; +using AnalysisData.Graph.Service.FileUploadService.Abstraction; +using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; using Microsoft.AspNetCore.Mvc; -namespace AnalysisData.EAV.Controllers; +namespace AnalysisData.Graph.Controllers; [ApiController] [Route("api/[controller]")] diff --git a/AnalysisData/AnalysisData/Graph/Controllers/GraphEavController.cs b/AnalysisData/AnalysisData/Graph/Controllers/GraphEavController.cs index 599ebeb..b07aaac 100644 --- a/AnalysisData/AnalysisData/Graph/Controllers/GraphEavController.cs +++ b/AnalysisData/AnalysisData/Graph/Controllers/GraphEavController.cs @@ -1,11 +1,10 @@ -using AnalysisData.Data; -using AnalysisData.EAV.Service.Abstraction; -using AnalysisData.EAV.Service.GraphServices.NodeAndEdgeServices; -using AnalysisData.EAV.Service.GraphServices.Relationship; -using AnalysisData.EAV.Service.GraphSevices; +using AnalysisData.Graph.Service.GraphServices.AllNodesData; +using AnalysisData.Graph.Service.GraphServices.NodeAndEdgeInfo; +using AnalysisData.Graph.Service.GraphServices.Relationship; +using AnalysisData.Graph.Service.GraphServices.Search; using Microsoft.AspNetCore.Mvc; -namespace AnalysisData.EAV.Controllers; +namespace AnalysisData.Graph.Controllers; [ApiController] [Route("api/[controller]")] diff --git a/AnalysisData/AnalysisData/Graph/Dto/AccessFileToUserDto.cs b/AnalysisData/AnalysisData/Graph/Dto/AccessFileToUserDto.cs index d3f89fd..04aa992 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/AccessFileToUserDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/AccessFileToUserDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto; public class AccessFileToUserDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/CategoryDto.cs b/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/CategoryDto.cs index a56b06a..58d5b4a 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/CategoryDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/CategoryDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Model; +namespace AnalysisData.Graph.Dto.CategoryDto; public class CategoryDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/NewCategoryDto.cs b/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/NewCategoryDto.cs index 2a58599..6333073 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/NewCategoryDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/NewCategoryDto.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto.CategoryDto; public class NewCategoryDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/PaginationCategoryDto.cs b/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/PaginationCategoryDto.cs index a5193bb..2c22826 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/PaginationCategoryDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/CategoryDto/PaginationCategoryDto.cs @@ -1,6 +1,4 @@ -using AnalysisData.EAV.Model; - -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto.CategoryDto; public class PaginationCategoryDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/EdgeDto/EdgeDto.cs b/AnalysisData/AnalysisData/Graph/Dto/EdgeDto/EdgeDto.cs index 038fe64..4f50775 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/EdgeDto/EdgeDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/EdgeDto/EdgeDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto.EdgeDto; public class EdgeDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/EdgeDto/EdgeUploadDto.cs b/AnalysisData/AnalysisData/Graph/Dto/EdgeDto/EdgeUploadDto.cs index fa665a4..a98a591 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/EdgeDto/EdgeUploadDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/EdgeDto/EdgeUploadDto.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto.EdgeDto; public class EdgeUploadDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/FileEntityDto.cs b/AnalysisData/AnalysisData/Graph/Dto/FileEntityDto.cs index 11660e7..723b843 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/FileEntityDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/FileEntityDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto; public class FileEntityDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/NodeDto/NodeDto.cs b/AnalysisData/AnalysisData/Graph/Dto/NodeDto/NodeDto.cs index 4a01c9c..6b8af43 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/NodeDto/NodeDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/NodeDto/NodeDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto.NodeDto; public class NodeDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/NodeDto/NodeUploadDto.cs b/AnalysisData/AnalysisData/Graph/Dto/NodeDto/NodeUploadDto.cs index 5cbb24f..b1c6ae9 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/NodeDto/NodeUploadDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/NodeDto/NodeUploadDto.cs @@ -1,7 +1,6 @@ using System.ComponentModel.DataAnnotations; -using AnalysisData.EAV.Model; -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto.NodeDto; public class NodeUploadDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/NodeDto/PaginatedNodeListDto.cs b/AnalysisData/AnalysisData/Graph/Dto/NodeDto/PaginatedNodeListDto.cs index 50cb25a..8cb0e34 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/NodeDto/PaginatedNodeListDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/NodeDto/PaginatedNodeListDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto.NodeDto; public class PaginatedNodeListDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/NodeDto/PaginationNodeDto.cs b/AnalysisData/AnalysisData/Graph/Dto/NodeDto/PaginationNodeDto.cs index b6e45c4..a79041b 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/NodeDto/PaginationNodeDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/NodeDto/PaginationNodeDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto.NodeDto; public class PaginationNodeDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/PaginatedFileDto.cs b/AnalysisData/AnalysisData/Graph/Dto/PaginatedFileDto.cs index 38f48a0..4a34444 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/PaginatedFileDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/PaginatedFileDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto; public class PaginatedFileDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/UserAccessDto.cs b/AnalysisData/AnalysisData/Graph/Dto/UserAccessDto.cs index eec91e5..762785e 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/UserAccessDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/UserAccessDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto; public class UserAccessDto { diff --git a/AnalysisData/AnalysisData/Graph/Dto/WhoAccessThisFileDto.cs b/AnalysisData/AnalysisData/Graph/Dto/WhoAccessThisFileDto.cs index 10d913a..c1945f0 100644 --- a/AnalysisData/AnalysisData/Graph/Dto/WhoAccessThisFileDto.cs +++ b/AnalysisData/AnalysisData/Graph/Dto/WhoAccessThisFileDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Dto; +namespace AnalysisData.Graph.Dto; public class WhoAccessThisFileDto { diff --git a/AnalysisData/AnalysisData/Graph/Model/Category/Category.cs b/AnalysisData/AnalysisData/Graph/Model/Category/Category.cs index 9b45503..59b8e67 100644 --- a/AnalysisData/AnalysisData/Graph/Model/Category/Category.cs +++ b/AnalysisData/AnalysisData/Graph/Model/Category/Category.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace AnalysisData.EAV.Model; +namespace AnalysisData.Graph.Model.Category; public class Category { diff --git a/AnalysisData/AnalysisData/Graph/Model/Edge/AttributeEdge.cs b/AnalysisData/AnalysisData/Graph/Model/Edge/AttributeEdge.cs index 1e82d06..ed8731b 100644 --- a/AnalysisData/AnalysisData/Graph/Model/Edge/AttributeEdge.cs +++ b/AnalysisData/AnalysisData/Graph/Model/Edge/AttributeEdge.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace AnalysisData.EAV.Model; +namespace AnalysisData.Graph.Model.Edge; public class AttributeEdge { diff --git a/AnalysisData/AnalysisData/Graph/Model/Edge/EntityEdge.cs b/AnalysisData/AnalysisData/Graph/Model/Edge/EntityEdge.cs index 72c1d7b..5f5a6fb 100644 --- a/AnalysisData/AnalysisData/Graph/Model/Edge/EntityEdge.cs +++ b/AnalysisData/AnalysisData/Graph/Model/Edge/EntityEdge.cs @@ -1,7 +1,8 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using AnalysisData.Graph.Model.Node; -namespace AnalysisData.EAV.Model; +namespace AnalysisData.Graph.Model.Edge; public class EntityEdge { diff --git a/AnalysisData/AnalysisData/Graph/Model/Edge/ValueEdge.cs b/AnalysisData/AnalysisData/Graph/Model/Edge/ValueEdge.cs index 192cec8..9d92540 100644 --- a/AnalysisData/AnalysisData/Graph/Model/Edge/ValueEdge.cs +++ b/AnalysisData/AnalysisData/Graph/Model/Edge/ValueEdge.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace AnalysisData.EAV.Model; +namespace AnalysisData.Graph.Model.Edge; public class ValueEdge { diff --git a/AnalysisData/AnalysisData/Graph/Model/File/FileEntity.cs b/AnalysisData/AnalysisData/Graph/Model/File/FileEntity.cs index 0d89aac..a87565f 100644 --- a/AnalysisData/AnalysisData/Graph/Model/File/FileEntity.cs +++ b/AnalysisData/AnalysisData/Graph/Model/File/FileEntity.cs @@ -1,8 +1,8 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using AnalysisData.UserManage.Model; +using AnalysisData.Graph.Model.Node; -namespace AnalysisData.EAV.Model; +namespace AnalysisData.Graph.Model.File; public class FileEntity { @@ -10,14 +10,14 @@ public class FileEntity public Guid UploaderId { get; set; } - [ForeignKey("UploaderId")] public User User { get; set; } + [ForeignKey("UploaderId")] public User.Model.User User { get; set; } [Required] public DateTime UploadDate { get; set; } public string FileName { get; set; } public int CategoryId { get; set; } - [ForeignKey("CategoryId")] public Category Category { get; set; } + [ForeignKey("CategoryId")] public Category.Category Category { get; set; } public ICollection EntityNodes { get; set; } } \ No newline at end of file diff --git a/AnalysisData/AnalysisData/Graph/Model/File/UserFile.cs b/AnalysisData/AnalysisData/Graph/Model/File/UserFile.cs index 80f1881..d5d3f69 100644 --- a/AnalysisData/AnalysisData/Graph/Model/File/UserFile.cs +++ b/AnalysisData/AnalysisData/Graph/Model/File/UserFile.cs @@ -1,8 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using AnalysisData.UserManage.Model; -namespace AnalysisData.EAV.Model; +namespace AnalysisData.Graph.Model.File; public class UserFile { @@ -10,7 +9,7 @@ public class UserFile public Guid UserId { get; set; } - [ForeignKey("UserId")] public User User { get; set; } + [ForeignKey("UserId")] public User.Model.User User { get; set; } public int FileId { get; set; } diff --git a/AnalysisData/AnalysisData/Graph/Model/Node/AttributeNode.cs b/AnalysisData/AnalysisData/Graph/Model/Node/AttributeNode.cs index 7c4ad93..ed53b1c 100644 --- a/AnalysisData/AnalysisData/Graph/Model/Node/AttributeNode.cs +++ b/AnalysisData/AnalysisData/Graph/Model/Node/AttributeNode.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace AnalysisData.EAV.Model; +namespace AnalysisData.Graph.Model.Node; public class AttributeNode { diff --git a/AnalysisData/AnalysisData/Graph/Model/Node/EntityNode.cs b/AnalysisData/AnalysisData/Graph/Model/Node/EntityNode.cs index 60d7278..3a4e7ef 100644 --- a/AnalysisData/AnalysisData/Graph/Model/Node/EntityNode.cs +++ b/AnalysisData/AnalysisData/Graph/Model/Node/EntityNode.cs @@ -1,7 +1,8 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using AnalysisData.Graph.Model.File; -namespace AnalysisData.EAV.Model; +namespace AnalysisData.Graph.Model.Node; public class EntityNode { diff --git a/AnalysisData/AnalysisData/Graph/Model/Node/ValueNode.cs b/AnalysisData/AnalysisData/Graph/Model/Node/ValueNode.cs index 4b88820..0ac53ae 100644 --- a/AnalysisData/AnalysisData/Graph/Model/Node/ValueNode.cs +++ b/AnalysisData/AnalysisData/Graph/Model/Node/ValueNode.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace AnalysisData.EAV.Model; +namespace AnalysisData.Graph.Model.Node; public class ValueNode { diff --git a/AnalysisData/AnalysisData/Graph/Repository/CategoryRepository/Abstraction/ICategoryRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/CategoryRepository/Abstraction/ICategoryRepository.cs index debc523..239c572 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/CategoryRepository/Abstraction/ICategoryRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/CategoryRepository/Abstraction/ICategoryRepository.cs @@ -1,7 +1,6 @@ -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Category; -namespace AnalysisData.EAV.Repository.CategoryRepository.asbtraction; +namespace AnalysisData.Graph.Repository.CategoryRepository.Abstraction; public interface ICategoryRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/CategoryRepository/CategoryRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/CategoryRepository/CategoryRepository.cs index c73adb0..2fbbd48 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/CategoryRepository/CategoryRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/CategoryRepository/CategoryRepository.cs @@ -1,10 +1,9 @@ using AnalysisData.Data; -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.CategoryRepository.asbtraction; +using AnalysisData.Graph.Model.Category; +using AnalysisData.Graph.Repository.CategoryRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository.CategoryRepository; +namespace AnalysisData.Graph.Repository.CategoryRepository; public class CategoryRepository : ICategoryRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IAttributeEdgeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IAttributeEdgeRepository.cs index 0542738..6d31efd 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IAttributeEdgeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IAttributeEdgeRepository.cs @@ -1,6 +1,6 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Edge; -namespace AnalysisData.EAV.Repository.EdgeRepository.Abstraction; +namespace AnalysisData.Graph.Repository.EdgeRepository.Abstraction; public interface IAttributeEdgeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IEntityEdgeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IEntityEdgeRepository.cs index 4977138..e474e1c 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IEntityEdgeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IEntityEdgeRepository.cs @@ -1,6 +1,6 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Edge; -namespace AnalysisData.EAV.Repository.EdgeRepository.Abstraction; +namespace AnalysisData.Graph.Repository.EdgeRepository.Abstraction; public interface IEntityEdgeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IValueEdgeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IValueEdgeRepository.cs index 3bcddaa..c149f28 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IValueEdgeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/Abstraction/IValueEdgeRepository.cs @@ -1,6 +1,6 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Edge; -namespace AnalysisData.EAV.Repository.EdgeRepository.Abstraction; +namespace AnalysisData.Graph.Repository.EdgeRepository.Abstraction; public interface IValueEdgeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/AttributeEdgeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/AttributeEdgeRepository.cs index 1186279..159cf7d 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/AttributeEdgeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/AttributeEdgeRepository.cs @@ -1,9 +1,9 @@ using AnalysisData.Data; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.EdgeRepository.Abstraction; +using AnalysisData.Graph.Model.Edge; +using AnalysisData.Graph.Repository.EdgeRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository.EdgeRepository; +namespace AnalysisData.Graph.Repository.EdgeRepository; public class AttributeEdgeRepository : IAttributeEdgeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/EntityEdgeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/EntityEdgeRepository.cs index ecb159f..b13cb83 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/EntityEdgeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/EntityEdgeRepository.cs @@ -1,9 +1,9 @@ using AnalysisData.Data; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.EdgeRepository.Abstraction; +using AnalysisData.Graph.Model.Edge; +using AnalysisData.Graph.Repository.EdgeRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository.EdgeRepository; +namespace AnalysisData.Graph.Repository.EdgeRepository; public class EntityEdgeRepository : IEntityEdgeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/ValueEdgeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/ValueEdgeRepository.cs index 8121eec..ad0597b 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/ValueEdgeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/EdgeRepository/ValueEdgeRepository.cs @@ -1,9 +1,9 @@ using AnalysisData.Data; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.EdgeRepository.Abstraction; +using AnalysisData.Graph.Model.Edge; +using AnalysisData.Graph.Repository.EdgeRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository.EdgeRepository; +namespace AnalysisData.Graph.Repository.EdgeRepository; public class ValueEdgeRepository : IValueEdgeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/FileUploadedRepository/Abstraction/IFileUploadedRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/FileUploadedRepository/Abstraction/IFileUploadedRepository.cs index 5212e18..c6ee6af 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/FileUploadedRepository/Abstraction/IFileUploadedRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/FileUploadedRepository/Abstraction/IFileUploadedRepository.cs @@ -1,6 +1,6 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.File; -namespace AnalysisData.EAV.Repository.FileUploadedRepository; +namespace AnalysisData.Graph.Repository.FileUploadedRepository.Abstraction; public interface IFileUploadedRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/FileUploadedRepository/FileUploadedRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/FileUploadedRepository/FileUploadedRepository.cs index 49940d4..6938122 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/FileUploadedRepository/FileUploadedRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/FileUploadedRepository/FileUploadedRepository.cs @@ -1,9 +1,9 @@ using AnalysisData.Data; -using AnalysisData.EAV.Model; -using AnalysisData.UserManage.Model; +using AnalysisData.Graph.Model.File; +using AnalysisData.Graph.Repository.FileUploadedRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository.FileUploadedRepository; +namespace AnalysisData.Graph.Repository.FileUploadedRepository; public class FileUploadedRepository : IFileUploadedRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/GraphEdgeRepository/GraphEdgeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/GraphEdgeRepository/GraphEdgeRepository.cs index 1c7bc20..5ec66dd 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/GraphEdgeRepository/GraphEdgeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/GraphEdgeRepository/GraphEdgeRepository.cs @@ -1,9 +1,7 @@ using AnalysisData.Data; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository; +namespace AnalysisData.Graph.Repository.GraphEdgeRepository; public class GraphEdgeRepository : IGraphEdgeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/GraphEdgeRepository/IGraphEdgeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/GraphEdgeRepository/IGraphEdgeRepository.cs index feded0d..a8b5190 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/GraphEdgeRepository/IGraphEdgeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/GraphEdgeRepository/IGraphEdgeRepository.cs @@ -1,6 +1,4 @@ -using AnalysisData.EAV.Model; - -namespace AnalysisData.EAV.Repository.Abstraction; +namespace AnalysisData.Graph.Repository.GraphEdgeRepository; public interface IGraphEdgeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/GraphNodeRepository/GraphNodeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/GraphNodeRepository/GraphNodeRepository.cs index 9e3da05..0833dc1 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/GraphNodeRepository/GraphNodeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/GraphNodeRepository/GraphNodeRepository.cs @@ -1,10 +1,8 @@ -using System.Security.Claims; -using AnalysisData.Data; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.Abstraction; +using AnalysisData.Data; +using AnalysisData.Graph.Model.Node; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository; +namespace AnalysisData.Graph.Repository.GraphNodeRepository; public class GraphNodeRepository : IGraphNodeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/GraphNodeRepository/IGraphNodeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/GraphNodeRepository/IGraphNodeRepository.cs index 24aca02..c506ad0 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/GraphNodeRepository/IGraphNodeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/GraphNodeRepository/IGraphNodeRepository.cs @@ -1,6 +1,6 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Node; -namespace AnalysisData.EAV.Repository.Abstraction; +namespace AnalysisData.Graph.Repository.GraphNodeRepository; public interface IGraphNodeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IAttributeNodeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IAttributeNodeRepository.cs index 9564138..c1d8253 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IAttributeNodeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IAttributeNodeRepository.cs @@ -1,6 +1,6 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Node; -namespace AnalysisData.EAV.Repository.NodeRepository.Abstraction; +namespace AnalysisData.Graph.Repository.NodeRepository.Abstraction; public interface IAttributeNodeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IEntityNodeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IEntityNodeRepository.cs index 07c07dc..461fb4c 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IEntityNodeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IEntityNodeRepository.cs @@ -1,6 +1,6 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Node; -namespace AnalysisData.EAV.Repository.NodeRepository.Abstraction; +namespace AnalysisData.Graph.Repository.NodeRepository.Abstraction; public interface IEntityNodeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IValueNodeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IValueNodeRepository.cs index e9513be..61b9c46 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IValueNodeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/Abstraction/IValueNodeRepository.cs @@ -1,6 +1,6 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Node; -namespace AnalysisData.EAV.Repository.NodeRepository.Abstraction; +namespace AnalysisData.Graph.Repository.NodeRepository.Abstraction; public interface IValueNodeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/AttributeNodeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/AttributeNodeRepository.cs index 5687f9e..0ad518b 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/AttributeNodeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/AttributeNodeRepository.cs @@ -1,9 +1,9 @@ using AnalysisData.Data; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.NodeRepository.Abstraction; +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository.NodeRepository; +namespace AnalysisData.Graph.Repository.NodeRepository; public class AttributeNodeRepository : IAttributeNodeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/EntityNodeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/EntityNodeRepository.cs index 8297c66..5a095f0 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/EntityNodeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/EntityNodeRepository.cs @@ -1,9 +1,9 @@ using AnalysisData.Data; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.NodeRepository.Abstraction; +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository.NodeRepository; +namespace AnalysisData.Graph.Repository.NodeRepository; public class EntityNodeRepository : IEntityNodeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/ValueNodeRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/ValueNodeRepository.cs index 9566740..426ff7d 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/ValueNodeRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/NodeRepository/ValueNodeRepository.cs @@ -1,9 +1,9 @@ using AnalysisData.Data; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.NodeRepository.Abstraction; +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository.NodeRepository; +namespace AnalysisData.Graph.Repository.NodeRepository; public class ValueNodeRepository : IValueNodeRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/UserFileRepository/Abstraction/IUserFileRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/UserFileRepository/Abstraction/IUserFileRepository.cs index a9c970c..6d936b0 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/UserFileRepository/Abstraction/IUserFileRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/UserFileRepository/Abstraction/IUserFileRepository.cs @@ -1,6 +1,6 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.File; -namespace AnalysisData.EAV.Repository.Abstraction; +namespace AnalysisData.Graph.Repository.UserFileRepository.Abstraction; public interface IUserFileRepository { diff --git a/AnalysisData/AnalysisData/Graph/Repository/UserFileRepository/UserFileRepository.cs b/AnalysisData/AnalysisData/Graph/Repository/UserFileRepository/UserFileRepository.cs index 6111df6..311428a 100644 --- a/AnalysisData/AnalysisData/Graph/Repository/UserFileRepository/UserFileRepository.cs +++ b/AnalysisData/AnalysisData/Graph/Repository/UserFileRepository/UserFileRepository.cs @@ -1,10 +1,9 @@ using AnalysisData.Data; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.Abstraction; -using AnalysisData.UserManage.Model; +using AnalysisData.Graph.Model.File; +using AnalysisData.Graph.Repository.UserFileRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.EAV.Repository; +namespace AnalysisData.Graph.Repository.UserFileRepository; public class UserFileRepository : IUserFileRepository { diff --git a/AnalysisData/AnalysisData/Graph/Service/CategoryService/Abstraction/ICategoryService.cs b/AnalysisData/AnalysisData/Graph/Service/CategoryService/Abstraction/ICategoryService.cs index f8d9dbe..d3dcb9a 100644 --- a/AnalysisData/AnalysisData/Graph/Service/CategoryService/Abstraction/ICategoryService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/CategoryService/Abstraction/ICategoryService.cs @@ -1,7 +1,7 @@ -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Dto.CategoryDto; +using AnalysisData.Graph.Model.Category; -namespace AnalysisData.EAV.Service.Abstraction; +namespace AnalysisData.Graph.Service.CategoryService.Abstraction; public interface ICategoryService { diff --git a/AnalysisData/AnalysisData/Graph/Service/CategoryService/CategoryService.cs b/AnalysisData/AnalysisData/Graph/Service/CategoryService/CategoryService.cs index 7c77db4..f4846d9 100644 --- a/AnalysisData/AnalysisData/Graph/Service/CategoryService/CategoryService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/CategoryService/CategoryService.cs @@ -1,11 +1,11 @@ -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.CategoryRepository.asbtraction; -using AnalysisData.EAV.Repository.FileUploadedRepository; -using AnalysisData.EAV.Service.Abstraction; -using AnalysisData.Exception; - -namespace AnalysisData.EAV.Service; +using AnalysisData.Exception.GraphException; +using AnalysisData.Graph.Dto.CategoryDto; +using AnalysisData.Graph.Model.Category; +using AnalysisData.Graph.Repository.CategoryRepository.Abstraction; +using AnalysisData.Graph.Repository.FileUploadedRepository.Abstraction; +using AnalysisData.Graph.Service.CategoryService.Abstraction; + +namespace AnalysisData.Graph.Service.CategoryService; public class CategoryService : ICategoryService { diff --git a/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/AccessMangement/AccessManagementService.cs b/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/AccessMangement/AccessManagementService.cs index 43b7b28..2ef9f18 100644 --- a/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/AccessMangement/AccessManagementService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/AccessMangement/AccessManagementService.cs @@ -1,8 +1,7 @@ -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.Abstraction; -using AnalysisData.Repository.UserRepository.Abstraction; +using AnalysisData.Graph.Model.File; +using AnalysisData.Graph.Repository.UserFileRepository.Abstraction; -namespace AnalysisData.EAV.Service; +namespace AnalysisData.Graph.Service.FilePermissionService.AccessMangement; public class AccessManagementService : IAccessManagementService { diff --git a/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/AccessMangement/IAccessManagementService.cs b/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/AccessMangement/IAccessManagementService.cs index 7c76cb4..82c25f5 100644 --- a/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/AccessMangement/IAccessManagementService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/AccessMangement/IAccessManagementService.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Service; +namespace AnalysisData.Graph.Service.FilePermissionService.AccessMangement; public interface IAccessManagementService { diff --git a/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/FilePermissionService.cs b/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/FilePermissionService.cs index 8d3c16c..1afac4b 100644 --- a/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/FilePermissionService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/FilePermissionService.cs @@ -1,12 +1,12 @@ -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.Abstraction; -using AnalysisData.EAV.Repository.FileUploadedRepository; -using AnalysisData.Exception; -using AnalysisData.Repository.UserRepository.Abstraction; -using AnalysisData.UserManage.Model; +using AnalysisData.Exception.GraphException; +using AnalysisData.Exception.UserException; +using AnalysisData.Graph.Dto; +using AnalysisData.Graph.Repository.FileUploadedRepository.Abstraction; +using AnalysisData.Graph.Repository.UserFileRepository.Abstraction; +using AnalysisData.Graph.Service.FilePermissionService.AccessMangement; +using AnalysisData.User.Repository.UserRepository.Abstraction; -namespace AnalysisData.EAV.Service; +namespace AnalysisData.Graph.Service.FilePermissionService; public class FilePermissionService : IFilePermissionService { diff --git a/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/IFilePermissionService.cs b/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/IFilePermissionService.cs index 7cc7abf..99ba848 100644 --- a/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/IFilePermissionService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/FilePermissionService/IFilePermissionService.cs @@ -1,8 +1,6 @@ -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Model; -using AnalysisData.UserManage.Model; +using AnalysisData.Graph.Dto; -namespace AnalysisData.EAV.Service; +namespace AnalysisData.Graph.Service.FilePermissionService; public interface IFilePermissionService { diff --git a/AnalysisData/AnalysisData/Graph/Service/FileUploadService/Abstraction/IUploadFileService.cs b/AnalysisData/AnalysisData/Graph/Service/FileUploadService/Abstraction/IUploadFileService.cs index 243e111..7e2e0dc 100644 --- a/AnalysisData/AnalysisData/Graph/Service/FileUploadService/Abstraction/IUploadFileService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/FileUploadService/Abstraction/IUploadFileService.cs @@ -1,6 +1,6 @@ using System.Security.Claims; -namespace AnalysisData.EAV.Service.Abstraction; +namespace AnalysisData.Graph.Service.FileUploadService.Abstraction; public interface IUploadFileService { diff --git a/AnalysisData/AnalysisData/Graph/Service/FileUploadService/UploadFileService.cs b/AnalysisData/AnalysisData/Graph/Service/FileUploadService/UploadFileService.cs index f04448f..97aaaa6 100644 --- a/AnalysisData/AnalysisData/Graph/Service/FileUploadService/UploadFileService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/FileUploadService/UploadFileService.cs @@ -1,10 +1,9 @@ using System.Security.Claims; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.Abstraction; -using AnalysisData.EAV.Repository.FileUploadedRepository; -using AnalysisData.EAV.Service.Abstraction; +using AnalysisData.Graph.Model.File; +using AnalysisData.Graph.Repository.FileUploadedRepository.Abstraction; +using AnalysisData.Graph.Service.FileUploadService.Abstraction; -namespace AnalysisData.EAV.Service; +namespace AnalysisData.Graph.Service.FileUploadService; public class UploadFileService : IUploadFileService { diff --git a/AnalysisData/AnalysisData/Graph/Service/GraphServices/AllNodesData/INodePaginationService.cs b/AnalysisData/AnalysisData/Graph/Service/GraphServices/AllNodesData/INodePaginationService.cs index f7fc694..15a8f9b 100644 --- a/AnalysisData/AnalysisData/Graph/Service/GraphServices/AllNodesData/INodePaginationService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/GraphServices/AllNodesData/INodePaginationService.cs @@ -1,8 +1,7 @@ using System.Security.Claims; -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Dto.NodeDto; -namespace AnalysisData.EAV.Service.Abstraction; +namespace AnalysisData.Graph.Service.GraphServices.AllNodesData; public interface INodePaginationService { diff --git a/AnalysisData/AnalysisData/Graph/Service/GraphServices/AllNodesData/NodePaginationService.cs b/AnalysisData/AnalysisData/Graph/Service/GraphServices/AllNodesData/NodePaginationService.cs index 25165b5..fda9df8 100644 --- a/AnalysisData/AnalysisData/Graph/Service/GraphServices/AllNodesData/NodePaginationService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/GraphServices/AllNodesData/NodePaginationService.cs @@ -1,13 +1,14 @@ using System.Security.Claims; -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.Abstraction; -using AnalysisData.EAV.Repository.NodeRepository.Abstraction; -using AnalysisData.EAV.Repository.EdgeRepository.Abstraction; -using AnalysisData.EAV.Service.Abstraction; -using AnalysisData.Exception; +using AnalysisData.Exception.GraphException; +using AnalysisData.Graph.Dto.NodeDto; +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.EdgeRepository.Abstraction; +using AnalysisData.Graph.Repository.GraphEdgeRepository; +using AnalysisData.Graph.Repository.GraphNodeRepository; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; +using AnalysisData.Graph.Service.CategoryService.Abstraction; -namespace AnalysisData.EAV.Service; +namespace AnalysisData.Graph.Service.GraphServices.AllNodesData; public class NodePaginationService : INodePaginationService { diff --git a/AnalysisData/AnalysisData/Graph/Service/GraphServices/NodeAndEdgeInfo/INodeAndEdgeInfo.cs b/AnalysisData/AnalysisData/Graph/Service/GraphServices/NodeAndEdgeInfo/INodeAndEdgeInfo.cs index 0c213a5..cee3e9e 100644 --- a/AnalysisData/AnalysisData/Graph/Service/GraphServices/NodeAndEdgeInfo/INodeAndEdgeInfo.cs +++ b/AnalysisData/AnalysisData/Graph/Service/GraphServices/NodeAndEdgeInfo/INodeAndEdgeInfo.cs @@ -1,6 +1,6 @@ using System.Security.Claims; -namespace AnalysisData.EAV.Service.GraphServices.NodeAndEdgeServices; +namespace AnalysisData.Graph.Service.GraphServices.NodeAndEdgeInfo; public interface INodeAndEdgeInfo { diff --git a/AnalysisData/AnalysisData/Graph/Service/GraphServices/NodeAndEdgeInfo/NodeAndEdgeInfo.cs b/AnalysisData/AnalysisData/Graph/Service/GraphServices/NodeAndEdgeInfo/NodeAndEdgeInfo.cs index 18eff60..e4a104e 100644 --- a/AnalysisData/AnalysisData/Graph/Service/GraphServices/NodeAndEdgeInfo/NodeAndEdgeInfo.cs +++ b/AnalysisData/AnalysisData/Graph/Service/GraphServices/NodeAndEdgeInfo/NodeAndEdgeInfo.cs @@ -1,8 +1,9 @@ using System.Security.Claims; -using AnalysisData.EAV.Repository.Abstraction; -using AnalysisData.Exception; +using AnalysisData.Exception.GraphException; +using AnalysisData.Graph.Repository.GraphEdgeRepository; +using AnalysisData.Graph.Repository.GraphNodeRepository; -namespace AnalysisData.EAV.Service.GraphServices.NodeAndEdgeServices; +namespace AnalysisData.Graph.Service.GraphServices.NodeAndEdgeInfo; public class NodeAndEdgeInfo : INodeAndEdgeInfo { diff --git a/AnalysisData/AnalysisData/Graph/Service/GraphServices/Relationship/GraphRelationService.cs b/AnalysisData/AnalysisData/Graph/Service/GraphServices/Relationship/GraphRelationService.cs index d143ee4..a0e126b 100644 --- a/AnalysisData/AnalysisData/Graph/Service/GraphServices/Relationship/GraphRelationService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/GraphServices/Relationship/GraphRelationService.cs @@ -1,12 +1,13 @@ using System.Security.Claims; -using AnalysisData.EAV.Dto; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.Abstraction; -using AnalysisData.EAV.Repository.EdgeRepository.Abstraction; -using AnalysisData.EAV.Repository.NodeRepository.Abstraction; -using AnalysisData.Exception; +using AnalysisData.Exception.GraphException; +using AnalysisData.Graph.Dto.EdgeDto; +using AnalysisData.Graph.Dto.NodeDto; +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.EdgeRepository.Abstraction; +using AnalysisData.Graph.Repository.GraphNodeRepository; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; -namespace AnalysisData.EAV.Service.GraphServices.Relationship; +namespace AnalysisData.Graph.Service.GraphServices.Relationship; public class GraphRelationService : IGraphRelationService { diff --git a/AnalysisData/AnalysisData/Graph/Service/GraphServices/Relationship/IGraphRelationService.cs b/AnalysisData/AnalysisData/Graph/Service/GraphServices/Relationship/IGraphRelationService.cs index e91ffdf..1623f32 100644 --- a/AnalysisData/AnalysisData/Graph/Service/GraphServices/Relationship/IGraphRelationService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/GraphServices/Relationship/IGraphRelationService.cs @@ -1,7 +1,8 @@ using System.Security.Claims; -using AnalysisData.EAV.Dto; +using AnalysisData.Graph.Dto.EdgeDto; +using AnalysisData.Graph.Dto.NodeDto; -namespace AnalysisData.EAV.Service.GraphServices.Relationship; +namespace AnalysisData.Graph.Service.GraphServices.Relationship; public interface IGraphRelationService { diff --git a/AnalysisData/AnalysisData/Graph/Service/GraphServices/Search/GraphSearchService.cs b/AnalysisData/AnalysisData/Graph/Service/GraphServices/Search/GraphSearchService.cs index cb720d9..abb7d02 100644 --- a/AnalysisData/AnalysisData/Graph/Service/GraphServices/Search/GraphSearchService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/GraphServices/Search/GraphSearchService.cs @@ -1,9 +1,9 @@ using System.Security.Claims; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.Abstraction; -using AnalysisData.Exception; +using AnalysisData.Exception.GraphException; +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.GraphNodeRepository; -namespace AnalysisData.EAV.Service.GraphSevices; +namespace AnalysisData.Graph.Service.GraphServices.Search; public class GraphSearchService : IGraphSearchService { diff --git a/AnalysisData/AnalysisData/Graph/Service/GraphServices/Search/IGraphSearchService.cs b/AnalysisData/AnalysisData/Graph/Service/GraphServices/Search/IGraphSearchService.cs index 2e3781c..30af572 100644 --- a/AnalysisData/AnalysisData/Graph/Service/GraphServices/Search/IGraphSearchService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/GraphServices/Search/IGraphSearchService.cs @@ -1,7 +1,7 @@ using System.Security.Claims; -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Node; -namespace AnalysisData.EAV.Service.GraphSevices; +namespace AnalysisData.Graph.Service.GraphServices.Search; public interface IGraphSearchService { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/ICsvReaderService.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/ICsvReaderService.cs index a2e0f4d..765da5b 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/ICsvReaderService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/ICsvReaderService.cs @@ -1,6 +1,6 @@ using CsvHelper; -namespace AnalysisData.EAV.Service.Business.Abstraction; +namespace AnalysisData.Graph.Service.ServiceBusiness.Abstraction; public interface ICsvReaderService { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEdgeRecordProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEdgeRecordProcessor.cs new file mode 100644 index 0000000..fba4811 --- /dev/null +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEdgeRecordProcessor.cs @@ -0,0 +1,9 @@ + +using CsvHelper; + +namespace AnalysisData.Graph.Service.ServiceBusiness.Abstraction; + +public interface IEdgeRecordProcessor +{ + Task ProcessRecordsAsync(CsvReader csv, IEnumerable headers, string from, string to); +} \ No newline at end of file diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEdgeToDbService.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEdgeToDbService.cs index 9129a93..446c163 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEdgeToDbService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEdgeToDbService.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Service.Abstraction; +namespace AnalysisData.Graph.Service.ServiceBusiness.Abstraction; public interface IEdgeToDbService { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEntityEdgeRecordProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEntityEdgeRecordProcessor.cs index cab498f..6e49f43 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEntityEdgeRecordProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IEntityEdgeRecordProcessor.cs @@ -1,4 +1,4 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Edge; using CsvHelper; namespace AnalysisData.Graph.Service.ServiceBusiness.Abstraction; diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IFromToProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IFromToProcessor.cs index 513abd3..0674a41 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IFromToProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IFromToProcessor.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Service.Business.Abstraction; +namespace AnalysisData.Graph.Service.ServiceBusiness.Abstraction; public interface IFromToProcessor { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IHeaderProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IHeaderProcessor.cs index a654c8b..7ad1ddc 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IHeaderProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IHeaderProcessor.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Service.Business.Abstraction; +namespace AnalysisData.Graph.Service.ServiceBusiness.Abstraction; public interface IHeaderProcessor { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/INodeRecordProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/INodeRecordProcessor.cs index b71e854..325fad9 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/INodeRecordProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/INodeRecordProcessor.cs @@ -1,7 +1,7 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Node; using CsvHelper; -namespace AnalysisData.EAV.Service.Business.Abstraction; +namespace AnalysisData.Graph.Service.ServiceBusiness.Abstraction; public interface INodeRecordProcessor { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/INodeToDbService.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/INodeToDbService.cs index db06dff..e7dd32c 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/INodeToDbService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/INodeToDbService.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.EAV.Service.Abstraction; +namespace AnalysisData.Graph.Service.ServiceBusiness.Abstraction; public interface INodeToDbService { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IValueEdgeProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IValueEdgeProcessor.cs index 4c3d35f..bd38764 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IValueEdgeProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IValueEdgeProcessor.cs @@ -1,4 +1,4 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Edge; using CsvHelper; namespace AnalysisData.Graph.Service.ServiceBusiness.Abstraction; diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IValueNodeProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IValueNodeProcessor.cs index ed6dee0..0fd0077 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IValueNodeProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/Abstraction/IValueNodeProcessor.cs @@ -1,4 +1,4 @@ -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.Node; using CsvHelper; namespace AnalysisData.Graph.Service.ServiceBusiness.Abstraction; diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/CsvReaderService.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/CsvReaderService.cs index 6f5a33b..737ed42 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/CsvReaderService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/CsvReaderService.cs @@ -1,11 +1,12 @@ using System.Globalization; using System.Text; -using AnalysisData.EAV.Service.Business.Abstraction; +using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; using AnalysisData.Exception; +using AnalysisData.Exception.GraphException; using CsvHelper; using CsvHelper.Configuration; -namespace AnalysisData.EAV.Service.Business; +namespace AnalysisData.Graph.Service.ServiceBusiness; public class CsvReaderService : ICsvReaderService { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EdgeRecordProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EdgeRecordProcessor.cs new file mode 100644 index 0000000..d91d7b6 --- /dev/null +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EdgeRecordProcessor.cs @@ -0,0 +1,35 @@ +using AnalysisData.Graph.Model.Edge; +using AnalysisData.Graph.Repository.EdgeRepository.Abstraction; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; +using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; +using CsvHelper; + +namespace AnalysisData.Graph.Service.ServiceBusiness; + +public class EdgeRecordProcessor : IEdgeRecordProcessor +{ + private readonly IEntityEdgeRepository _entityEdgeRepository; + private readonly IAttributeEdgeRepository _attributeEdgeRepository; + private readonly IValueEdgeRepository _valueEdgeRepository; + private readonly IEntityNodeRepository _entityNodeRepository; + + public EdgeRecordProcessor(IEntityEdgeRepository entityEdgeRepository, + IAttributeEdgeRepository attributeEdgeRepository, IValueEdgeRepository valueEdgeRepository, + IEntityNodeRepository entityNodeRepository) + { + _entityEdgeRepository = entityEdgeRepository; + _attributeEdgeRepository = attributeEdgeRepository; + _valueEdgeRepository = valueEdgeRepository; + _entityNodeRepository = entityNodeRepository; + } + + public async Task ProcessRecordsAsync(CsvReader csv, IEnumerable headers, string from, string to) + { + while (await csv.ReadAsync()) + { + var fromId = csv.GetField(from); + var toId = csv.GetField(to); + if (string.IsNullOrEmpty(fromId) || string.IsNullOrEmpty(toId)) continue; + } + } +} \ No newline at end of file diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EdgeToDbService.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EdgeToDbService.cs index df2f9ab..ef14fd7 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EdgeToDbService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EdgeToDbService.cs @@ -1,8 +1,7 @@ -using AnalysisData.EAV.Service.Abstraction; -using AnalysisData.EAV.Service.Business.Abstraction; -using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; +using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; -namespace AnalysisData.EAV.Service; + +namespace AnalysisData.Graph.Service.ServiceBusiness; public class EdgeToDbService : IEdgeToDbService { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EntityEdgeRecordProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EntityEdgeRecordProcessor.cs index f1b7c6b..06dec79 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EntityEdgeRecordProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EntityEdgeRecordProcessor.cs @@ -1,7 +1,10 @@ -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.EdgeRepository.Abstraction; -using AnalysisData.EAV.Repository.NodeRepository.Abstraction; + using AnalysisData.Exception; +using AnalysisData.Exception.GraphException; +using AnalysisData.Graph.Model.Edge; +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.EdgeRepository.Abstraction; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; using CsvHelper; diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EntityNodeRecordProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EntityNodeRecordProcessor.cs index ce13032..4572942 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EntityNodeRecordProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/EntityNodeRecordProcessor.cs @@ -1,10 +1,9 @@ -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.NodeRepository.Abstraction; -using AnalysisData.EAV.Service.Business.Abstraction; +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; +using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; using CsvHelper; -using Microsoft.Extensions.Azure; -namespace AnalysisData.EAV.Service.Business; +namespace AnalysisData.Graph.Service.ServiceBusiness; public class EntityNodeRecordProcessor : INodeRecordProcessor { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/FromToProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/FromToProcessor.cs index 42da010..a4658ba 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/FromToProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/FromToProcessor.cs @@ -1,8 +1,8 @@ -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.EdgeRepository.Abstraction; -using AnalysisData.EAV.Service.Business.Abstraction; +using AnalysisData.Graph.Model.Edge; +using AnalysisData.Graph.Repository.EdgeRepository.Abstraction; +using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; -namespace AnalysisData.EAV.Service.Business; +namespace AnalysisData.Graph.Service.ServiceBusiness; public class FromToProcessor : IFromToProcessor { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/HeaderProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/HeaderProcessor.cs index 9e7df0c..2250202 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/HeaderProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/HeaderProcessor.cs @@ -1,8 +1,8 @@ -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.NodeRepository.Abstraction; -using AnalysisData.EAV.Service.Business.Abstraction; +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; +using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; -namespace AnalysisData.EAV.Service.Business; +namespace AnalysisData.Graph.Service.ServiceBusiness; public class HeaderProcessor : IHeaderProcessor { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/NodeRecordProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/NodeRecordProcessor.cs new file mode 100644 index 0000000..ee607e6 --- /dev/null +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/NodeRecordProcessor.cs @@ -0,0 +1,6 @@ +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; +using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; +using CsvHelper; + +namespace AnalysisData.Graph.Service.ServiceBusiness; diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/NodeToDbService.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/NodeToDbService.cs index 54ef391..006e0f0 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/NodeToDbService.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/NodeToDbService.cs @@ -1,9 +1,8 @@ -using AnalysisData.EAV.Service.Abstraction; -using AnalysisData.EAV.Service.Business.Abstraction; -using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; +using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; using CsvHelper; +using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; -namespace AnalysisData.EAV.Service; +namespace AnalysisData.Graph.Service.ServiceBusiness; public class NodeToDbService : INodeToDbService { diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/ValueEdgeProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/ValueEdgeProcessor.cs index 8ad187a..fdc717c 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/ValueEdgeProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/ValueEdgeProcessor.cs @@ -1,5 +1,5 @@ -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.EdgeRepository.Abstraction; +using AnalysisData.Graph.Model.Edge; +using AnalysisData.Graph.Repository.EdgeRepository.Abstraction; using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; using CsvHelper; diff --git a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/ValueNodeProcessor.cs b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/ValueNodeProcessor.cs index e8fa8a9..92ba0ec 100644 --- a/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/ValueNodeProcessor.cs +++ b/AnalysisData/AnalysisData/Graph/Service/ServiceBusiness/ValueNodeProcessor.cs @@ -1,6 +1,6 @@ -using System.Collections; -using AnalysisData.EAV.Model; -using AnalysisData.EAV.Repository.NodeRepository.Abstraction; + +using AnalysisData.Graph.Model.Node; +using AnalysisData.Graph.Repository.NodeRepository.Abstraction; using AnalysisData.Graph.Service.ServiceBusiness.Abstraction; using CsvHelper; diff --git a/AnalysisData/AnalysisData/Migrations/20240903222320_initial.Designer.cs b/AnalysisData/AnalysisData/Migrations/20240903222320_initial.Designer.cs deleted file mode 100644 index 9ac7250..0000000 --- a/AnalysisData/AnalysisData/Migrations/20240903222320_initial.Designer.cs +++ /dev/null @@ -1,458 +0,0 @@ -// -using System; -using AnalysisData.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace AnalysisData.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240903222320_initial")] - partial class initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("AnalysisData.EAV.Model.AttributeEdge", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("AttributeEdges"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.AttributeNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("AttributeNodes"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.Category", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.EntityEdge", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityIDSource") - .HasColumnType("integer"); - - b.Property("EntityIDTarget") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("EntityIDSource"); - - b.HasIndex("EntityIDTarget"); - - b.ToTable("EntityEdges"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.EntityNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("NodeFileReferenceId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("NodeFileReferenceId"); - - b.ToTable("EntityNodes"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.FileEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("FileName") - .IsRequired() - .HasColumnType("text"); - - b.Property("UploadDate") - .HasColumnType("timestamp with time zone"); - - b.Property("UploaderId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.HasIndex("UploaderId"); - - b.ToTable("FileUploadedDb"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.UserFile", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("FileId") - .HasColumnType("integer"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("FileId"); - - b.HasIndex("UserId"); - - b.ToTable("UserFiles"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.ValueEdge", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AttributeId") - .HasColumnType("integer"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("Value") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("AttributeId"); - - b.HasIndex("EntityId"); - - b.ToTable("ValueEdges"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.ValueNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AttributeId") - .HasColumnType("integer"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("Value") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("AttributeId"); - - b.HasIndex("EntityId"); - - b.ToTable("ValueNodes"); - }); - - modelBuilder.Entity("AnalysisData.UserManage.Model.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("RoleName") - .IsRequired() - .HasColumnType("text"); - - b.Property("RolePolicy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Roles"); - - b.HasData( - new - { - Id = 1, - RoleName = "admin", - RolePolicy = "gold" - }, - new - { - Id = 2, - RoleName = "Data-Analyst", - RolePolicy = "bronze" - }, - new - { - Id = 3, - RoleName = "Data-Manager", - RolePolicy = "silver" - }); - }); - - modelBuilder.Entity("AnalysisData.UserManage.Model.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Email") - .IsRequired() - .HasColumnType("text"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("ImageURL") - .HasColumnType("text"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("Password") - .IsRequired() - .HasColumnType("text"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("Username") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("Users"); - - b.HasData( - new - { - Id = new Guid("e44c5d6f-a7ff-44ce-96f6-35eeb102ccdc"), - Email = "admin@gmail.com", - FirstName = "admin", - LastName = "admin", - Password = "jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg=", - PhoneNumber = "09131111111", - RoleId = 1, - Username = "admin" - }); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.EntityEdge", b => - { - b.HasOne("AnalysisData.EAV.Model.EntityNode", "SourceNode") - .WithMany() - .HasForeignKey("EntityIDSource") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AnalysisData.EAV.Model.EntityNode", "TargetNode") - .WithMany() - .HasForeignKey("EntityIDTarget") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("SourceNode"); - - b.Navigation("TargetNode"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.EntityNode", b => - { - b.HasOne("AnalysisData.EAV.Model.FileEntity", "FileEntity") - .WithMany("EntityNodes") - .HasForeignKey("NodeFileReferenceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("FileEntity"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.FileEntity", b => - { - b.HasOne("AnalysisData.EAV.Model.Category", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AnalysisData.UserManage.Model.User", "User") - .WithMany("UploadData") - .HasForeignKey("UploaderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Category"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.UserFile", b => - { - b.HasOne("AnalysisData.EAV.Model.FileEntity", "FileEntity") - .WithMany() - .HasForeignKey("FileId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AnalysisData.UserManage.Model.User", "User") - .WithMany("UserFiles") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("FileEntity"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.ValueEdge", b => - { - b.HasOne("AnalysisData.EAV.Model.AttributeEdge", "Attribute") - .WithMany() - .HasForeignKey("AttributeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AnalysisData.EAV.Model.EntityEdge", "Entity") - .WithMany() - .HasForeignKey("EntityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Attribute"); - - b.Navigation("Entity"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.ValueNode", b => - { - b.HasOne("AnalysisData.EAV.Model.AttributeNode", "Attribute") - .WithMany() - .HasForeignKey("AttributeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AnalysisData.EAV.Model.EntityNode", "Entity") - .WithMany() - .HasForeignKey("EntityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Attribute"); - - b.Navigation("Entity"); - }); - - modelBuilder.Entity("AnalysisData.UserManage.Model.User", b => - { - b.HasOne("AnalysisData.UserManage.Model.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Role"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.FileEntity", b => - { - b.Navigation("EntityNodes"); - }); - - modelBuilder.Entity("AnalysisData.UserManage.Model.User", b => - { - b.Navigation("UploadData"); - - b.Navigation("UserFiles"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/AnalysisData/AnalysisData/Migrations/20240903222320_initial.cs b/AnalysisData/AnalysisData/Migrations/20240903222320_initial.cs deleted file mode 100644 index f6e4987..0000000 --- a/AnalysisData/AnalysisData/Migrations/20240903222320_initial.cs +++ /dev/null @@ -1,361 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace AnalysisData.Migrations -{ - /// - public partial class initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AttributeEdges", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AttributeEdges", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AttributeNodes", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AttributeNodes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Categories", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Categories", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Roles", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RoleName = table.Column(type: "text", nullable: false), - RolePolicy = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Roles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - Username = table.Column(type: "text", nullable: false), - Password = table.Column(type: "text", nullable: false), - FirstName = table.Column(type: "text", nullable: false), - LastName = table.Column(type: "text", nullable: false), - Email = table.Column(type: "text", nullable: false), - PhoneNumber = table.Column(type: "text", nullable: false), - ImageURL = table.Column(type: "text", nullable: true), - RoleId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - table.ForeignKey( - name: "FK_Users_Roles_RoleId", - column: x => x.RoleId, - principalTable: "Roles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FileUploadedDb", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - UploaderId = table.Column(type: "uuid", nullable: false), - UploadDate = table.Column(type: "timestamp with time zone", nullable: false), - FileName = table.Column(type: "text", nullable: false), - CategoryId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_FileUploadedDb", x => x.Id); - table.ForeignKey( - name: "FK_FileUploadedDb_Categories_CategoryId", - column: x => x.CategoryId, - principalTable: "Categories", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_FileUploadedDb_Users_UploaderId", - column: x => x.UploaderId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "EntityNodes", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), - NodeFileReferenceId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_EntityNodes", x => x.Id); - table.ForeignKey( - name: "FK_EntityNodes_FileUploadedDb_NodeFileReferenceId", - column: x => x.NodeFileReferenceId, - principalTable: "FileUploadedDb", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UserFiles", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - UserId = table.Column(type: "uuid", nullable: false), - FileId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_UserFiles", x => x.Id); - table.ForeignKey( - name: "FK_UserFiles_FileUploadedDb_FileId", - column: x => x.FileId, - principalTable: "FileUploadedDb", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_UserFiles_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "EntityEdges", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EntityIDSource = table.Column(type: "integer", nullable: false), - EntityIDTarget = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_EntityEdges", x => x.Id); - table.ForeignKey( - name: "FK_EntityEdges_EntityNodes_EntityIDSource", - column: x => x.EntityIDSource, - principalTable: "EntityNodes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_EntityEdges_EntityNodes_EntityIDTarget", - column: x => x.EntityIDTarget, - principalTable: "EntityNodes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ValueNodes", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Value = table.Column(type: "text", nullable: false), - EntityId = table.Column(type: "integer", nullable: false), - AttributeId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ValueNodes", x => x.Id); - table.ForeignKey( - name: "FK_ValueNodes_AttributeNodes_AttributeId", - column: x => x.AttributeId, - principalTable: "AttributeNodes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ValueNodes_EntityNodes_EntityId", - column: x => x.EntityId, - principalTable: "EntityNodes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ValueEdges", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EntityId = table.Column(type: "integer", nullable: false), - AttributeId = table.Column(type: "integer", nullable: false), - Value = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ValueEdges", x => x.Id); - table.ForeignKey( - name: "FK_ValueEdges_AttributeEdges_AttributeId", - column: x => x.AttributeId, - principalTable: "AttributeEdges", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ValueEdges_EntityEdges_EntityId", - column: x => x.EntityId, - principalTable: "EntityEdges", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.InsertData( - table: "Roles", - columns: new[] { "Id", "RoleName", "RolePolicy" }, - values: new object[,] - { - { 1, "admin", "gold" }, - { 2, "Data-Analyst", "bronze" }, - { 3, "Data-Manager", "silver" } - }); - - migrationBuilder.InsertData( - table: "Users", - columns: new[] { "Id", "Email", "FirstName", "ImageURL", "LastName", "Password", "PhoneNumber", "RoleId", "Username" }, - values: new object[] { new Guid("e44c5d6f-a7ff-44ce-96f6-35eeb102ccdc"), "admin@gmail.com", "admin", null, "admin", "jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg=", "09131111111", 1, "admin" }); - - migrationBuilder.CreateIndex( - name: "IX_EntityEdges_EntityIDSource", - table: "EntityEdges", - column: "EntityIDSource"); - - migrationBuilder.CreateIndex( - name: "IX_EntityEdges_EntityIDTarget", - table: "EntityEdges", - column: "EntityIDTarget"); - - migrationBuilder.CreateIndex( - name: "IX_EntityNodes_NodeFileReferenceId", - table: "EntityNodes", - column: "NodeFileReferenceId"); - - migrationBuilder.CreateIndex( - name: "IX_FileUploadedDb_CategoryId", - table: "FileUploadedDb", - column: "CategoryId"); - - migrationBuilder.CreateIndex( - name: "IX_FileUploadedDb_UploaderId", - table: "FileUploadedDb", - column: "UploaderId"); - - migrationBuilder.CreateIndex( - name: "IX_UserFiles_FileId", - table: "UserFiles", - column: "FileId"); - - migrationBuilder.CreateIndex( - name: "IX_UserFiles_UserId", - table: "UserFiles", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_RoleId", - table: "Users", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_ValueEdges_AttributeId", - table: "ValueEdges", - column: "AttributeId"); - - migrationBuilder.CreateIndex( - name: "IX_ValueEdges_EntityId", - table: "ValueEdges", - column: "EntityId"); - - migrationBuilder.CreateIndex( - name: "IX_ValueNodes_AttributeId", - table: "ValueNodes", - column: "AttributeId"); - - migrationBuilder.CreateIndex( - name: "IX_ValueNodes_EntityId", - table: "ValueNodes", - column: "EntityId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "UserFiles"); - - migrationBuilder.DropTable( - name: "ValueEdges"); - - migrationBuilder.DropTable( - name: "ValueNodes"); - - migrationBuilder.DropTable( - name: "AttributeEdges"); - - migrationBuilder.DropTable( - name: "EntityEdges"); - - migrationBuilder.DropTable( - name: "AttributeNodes"); - - migrationBuilder.DropTable( - name: "EntityNodes"); - - migrationBuilder.DropTable( - name: "FileUploadedDb"); - - migrationBuilder.DropTable( - name: "Categories"); - - migrationBuilder.DropTable( - name: "Users"); - - migrationBuilder.DropTable( - name: "Roles"); - } - } -} diff --git a/AnalysisData/AnalysisData/Migrations/ApplicationDbContextModelSnapshot.cs b/AnalysisData/AnalysisData/Migrations/ApplicationDbContextModelSnapshot.cs deleted file mode 100644 index 0154323..0000000 --- a/AnalysisData/AnalysisData/Migrations/ApplicationDbContextModelSnapshot.cs +++ /dev/null @@ -1,455 +0,0 @@ -// -using System; -using AnalysisData.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace AnalysisData.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - partial class ApplicationDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("AnalysisData.EAV.Model.AttributeEdge", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("AttributeEdges"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.AttributeNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("AttributeNodes"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.Category", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.EntityEdge", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityIDSource") - .HasColumnType("integer"); - - b.Property("EntityIDTarget") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("EntityIDSource"); - - b.HasIndex("EntityIDTarget"); - - b.ToTable("EntityEdges"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.EntityNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("NodeFileReferenceId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("NodeFileReferenceId"); - - b.ToTable("EntityNodes"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.FileEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("FileName") - .IsRequired() - .HasColumnType("text"); - - b.Property("UploadDate") - .HasColumnType("timestamp with time zone"); - - b.Property("UploaderId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.HasIndex("UploaderId"); - - b.ToTable("FileUploadedDb"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.UserFile", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("FileId") - .HasColumnType("integer"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("FileId"); - - b.HasIndex("UserId"); - - b.ToTable("UserFiles"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.ValueEdge", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AttributeId") - .HasColumnType("integer"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("Value") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("AttributeId"); - - b.HasIndex("EntityId"); - - b.ToTable("ValueEdges"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.ValueNode", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AttributeId") - .HasColumnType("integer"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("Value") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("AttributeId"); - - b.HasIndex("EntityId"); - - b.ToTable("ValueNodes"); - }); - - modelBuilder.Entity("AnalysisData.UserManage.Model.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("RoleName") - .IsRequired() - .HasColumnType("text"); - - b.Property("RolePolicy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Roles"); - - b.HasData( - new - { - Id = 1, - RoleName = "admin", - RolePolicy = "gold" - }, - new - { - Id = 2, - RoleName = "Data-Analyst", - RolePolicy = "bronze" - }, - new - { - Id = 3, - RoleName = "Data-Manager", - RolePolicy = "silver" - }); - }); - - modelBuilder.Entity("AnalysisData.UserManage.Model.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Email") - .IsRequired() - .HasColumnType("text"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("ImageURL") - .HasColumnType("text"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("Password") - .IsRequired() - .HasColumnType("text"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("Username") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("Users"); - - b.HasData( - new - { - Id = new Guid("e44c5d6f-a7ff-44ce-96f6-35eeb102ccdc"), - Email = "admin@gmail.com", - FirstName = "admin", - LastName = "admin", - Password = "jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg=", - PhoneNumber = "09131111111", - RoleId = 1, - Username = "admin" - }); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.EntityEdge", b => - { - b.HasOne("AnalysisData.EAV.Model.EntityNode", "SourceNode") - .WithMany() - .HasForeignKey("EntityIDSource") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AnalysisData.EAV.Model.EntityNode", "TargetNode") - .WithMany() - .HasForeignKey("EntityIDTarget") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("SourceNode"); - - b.Navigation("TargetNode"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.EntityNode", b => - { - b.HasOne("AnalysisData.EAV.Model.FileEntity", "FileEntity") - .WithMany("EntityNodes") - .HasForeignKey("NodeFileReferenceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("FileEntity"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.FileEntity", b => - { - b.HasOne("AnalysisData.EAV.Model.Category", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AnalysisData.UserManage.Model.User", "User") - .WithMany("UploadData") - .HasForeignKey("UploaderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Category"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.UserFile", b => - { - b.HasOne("AnalysisData.EAV.Model.FileEntity", "FileEntity") - .WithMany() - .HasForeignKey("FileId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AnalysisData.UserManage.Model.User", "User") - .WithMany("UserFiles") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("FileEntity"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.ValueEdge", b => - { - b.HasOne("AnalysisData.EAV.Model.AttributeEdge", "Attribute") - .WithMany() - .HasForeignKey("AttributeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AnalysisData.EAV.Model.EntityEdge", "Entity") - .WithMany() - .HasForeignKey("EntityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Attribute"); - - b.Navigation("Entity"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.ValueNode", b => - { - b.HasOne("AnalysisData.EAV.Model.AttributeNode", "Attribute") - .WithMany() - .HasForeignKey("AttributeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AnalysisData.EAV.Model.EntityNode", "Entity") - .WithMany() - .HasForeignKey("EntityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Attribute"); - - b.Navigation("Entity"); - }); - - modelBuilder.Entity("AnalysisData.UserManage.Model.User", b => - { - b.HasOne("AnalysisData.UserManage.Model.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Role"); - }); - - modelBuilder.Entity("AnalysisData.EAV.Model.FileEntity", b => - { - b.Navigation("EntityNodes"); - }); - - modelBuilder.Entity("AnalysisData.UserManage.Model.User", b => - { - b.Navigation("UploadData"); - - b.Navigation("UserFiles"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/AnalysisData/AnalysisData/Program.cs b/AnalysisData/AnalysisData/Program.cs index 9763b88..488f8f1 100644 --- a/AnalysisData/AnalysisData/Program.cs +++ b/AnalysisData/AnalysisData/Program.cs @@ -1,8 +1,7 @@ using System.Text; using AnalysisData; using AnalysisData.Data; -using AnalysisData.MiddleWare; -using AnalysisData.Repository.RoleRepository.Abstraction; +using AnalysisData.User.MiddleWare; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; diff --git a/AnalysisData/AnalysisData/User/Controllers/AdminController.cs b/AnalysisData/AnalysisData/User/Controllers/AdminController.cs index 607df34..e1062cf 100644 --- a/AnalysisData/AnalysisData/User/Controllers/AdminController.cs +++ b/AnalysisData/AnalysisData/User/Controllers/AdminController.cs @@ -1,11 +1,9 @@ -using AnalysisData.Services; -using AnalysisData.Services.Abstraction; -using AnalysisData.UserManage.RegisterModel; -using AnalysisData.UserManage.UpdateModel; +using AnalysisData.User.Services.AdminService.Abstraction; +using AnalysisData.User.UserDto.UserDto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -namespace AnalysisData.Controllers; +namespace AnalysisData.User.Controllers; [ApiController] //[Authorize(Roles = "admin")] @@ -64,4 +62,5 @@ public async Task UpdateUser(Guid id, [FromBody] UpdateAdminDto u return Ok(new { massage = "updated successfully" }); } + } \ No newline at end of file diff --git a/AnalysisData/AnalysisData/User/Controllers/RoleController.cs b/AnalysisData/AnalysisData/User/Controllers/RoleController.cs index 95b6591..8bef2e5 100644 --- a/AnalysisData/AnalysisData/User/Controllers/RoleController.cs +++ b/AnalysisData/AnalysisData/User/Controllers/RoleController.cs @@ -1,9 +1,8 @@ -using AnalysisData.Services; -using AnalysisData.UserManage.Model; -using AnalysisData.UserManage.RolePaginationModel; +using AnalysisData.User.Services.RoleService.Abstraction; +using AnalysisData.User.UserDto.RoleDto; using Microsoft.AspNetCore.Mvc; -namespace AnalysisData.Controllers; +namespace AnalysisData.User.Controllers; [ApiController] [Route("api/[controller]")] diff --git a/AnalysisData/AnalysisData/User/Controllers/UserController.cs b/AnalysisData/AnalysisData/User/Controllers/UserController.cs index dcddd7f..296cc48 100644 --- a/AnalysisData/AnalysisData/User/Controllers/UserController.cs +++ b/AnalysisData/AnalysisData/User/Controllers/UserController.cs @@ -1,17 +1,12 @@ using System.Security.Claims; -using AnalysisData.Exception; -using AnalysisData.Services; -using AnalysisData.Services.Abstraction; -using AnalysisData.UserDto.UserDto; -using AnalysisData.UserManage.LoginModel; -using AnalysisData.UserManage.NewPasswordModel; -using AnalysisData.UserManage.RegisterModel; -using AnalysisData.UserManage.ResetPasswordModel; -using AnalysisData.UserManage.UpdateModel; +using AnalysisData.User.Services.PermissionService.Abstraction; +using AnalysisData.User.Services.UserService.Abstraction; +using AnalysisData.User.UserDto.PasswordDto; +using AnalysisData.User.UserDto.UserDto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -namespace AnalysisData.Controllers; +namespace AnalysisData.User.Controllers; [ApiController] [Route("api/[controller]")] diff --git a/AnalysisData/AnalysisData/User/CookieService/CookieService.cs b/AnalysisData/AnalysisData/User/CookieService/CookieService.cs index a16e433..d73a2a7 100644 --- a/AnalysisData/AnalysisData/User/CookieService/CookieService.cs +++ b/AnalysisData/AnalysisData/User/CookieService/CookieService.cs @@ -1,6 +1,6 @@ -using AnalysisData.CookieService.abstractions; +using AnalysisData.User.CookieService.abstractions; -namespace AnalysisData.CookieService; +namespace AnalysisData.User.CookieService; public class CookieService : ICookieService { diff --git a/AnalysisData/AnalysisData/User/CookieService/abstractions/ICookieService.cs b/AnalysisData/AnalysisData/User/CookieService/abstractions/ICookieService.cs index e4af40d..066b8ab 100644 --- a/AnalysisData/AnalysisData/User/CookieService/abstractions/ICookieService.cs +++ b/AnalysisData/AnalysisData/User/CookieService/abstractions/ICookieService.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.CookieService.abstractions; +namespace AnalysisData.User.CookieService.abstractions; public interface ICookieService { diff --git a/AnalysisData/AnalysisData/User/JwtService/JwtService.cs b/AnalysisData/AnalysisData/User/JwtService/JwtService.cs index 92fa72a..11c0037 100644 --- a/AnalysisData/AnalysisData/User/JwtService/JwtService.cs +++ b/AnalysisData/AnalysisData/User/JwtService/JwtService.cs @@ -1,14 +1,12 @@ using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; using System.Text; -using AnalysisData.CookieService.abstractions; -using AnalysisData.Exception; -using AnalysisData.JwtService.abstractions; -using AnalysisData.Repository.UserRepository.Abstraction; -using JWT.Exceptions; +using AnalysisData.User.CookieService.abstractions; +using AnalysisData.User.JwtService.abstractions; +using AnalysisData.User.Repository.UserRepository.Abstraction; using Microsoft.IdentityModel.Tokens; -namespace AnalysisData.JwtService; +namespace AnalysisData.User.JwtService; public class JwtService : IJwtService { diff --git a/AnalysisData/AnalysisData/User/JwtService/abstractions/IJwtService.cs b/AnalysisData/AnalysisData/User/JwtService/abstractions/IJwtService.cs index 516d806..7333333 100644 --- a/AnalysisData/AnalysisData/User/JwtService/abstractions/IJwtService.cs +++ b/AnalysisData/AnalysisData/User/JwtService/abstractions/IJwtService.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.JwtService.abstractions; +namespace AnalysisData.User.JwtService.abstractions; public interface IJwtService { diff --git a/AnalysisData/AnalysisData/User/MiddleWare/ExceptionHandlingMiddleware.cs b/AnalysisData/AnalysisData/User/MiddleWare/ExceptionHandlingMiddleware.cs index 3fe5e83..3413cd1 100644 --- a/AnalysisData/AnalysisData/User/MiddleWare/ExceptionHandlingMiddleware.cs +++ b/AnalysisData/AnalysisData/User/MiddleWare/ExceptionHandlingMiddleware.cs @@ -1,8 +1,9 @@ using System.ComponentModel.DataAnnotations; using AnalysisData.Exception; +using AnalysisData.Exception.UserException; using Microsoft.IdentityModel.Tokens; -namespace AnalysisData.MiddleWare; +namespace AnalysisData.User.MiddleWare; public class ExceptionHandlingMiddleware { diff --git a/AnalysisData/AnalysisData/User/MiddleWare/JwtMiddleware.cs b/AnalysisData/AnalysisData/User/MiddleWare/JwtMiddleware.cs index be26368..d3b9626 100644 --- a/AnalysisData/AnalysisData/User/MiddleWare/JwtMiddleware.cs +++ b/AnalysisData/AnalysisData/User/MiddleWare/JwtMiddleware.cs @@ -2,7 +2,7 @@ using System.Text; using Microsoft.IdentityModel.Tokens; -namespace AnalysisData.MiddleWare; +namespace AnalysisData.User.MiddleWare; public class JwtMiddleware { diff --git a/AnalysisData/AnalysisData/User/Model/RegexPatterns.cs b/AnalysisData/AnalysisData/User/Model/RegexPatterns.cs index dd3a6f9..114e1fc 100644 --- a/AnalysisData/AnalysisData/User/Model/RegexPatterns.cs +++ b/AnalysisData/AnalysisData/User/Model/RegexPatterns.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserManage.Model; +namespace AnalysisData.User.Model; public static class RegexPatterns { diff --git a/AnalysisData/AnalysisData/User/Model/Role.cs b/AnalysisData/AnalysisData/User/Model/Role.cs index 1ced0ea..67b982c 100644 --- a/AnalysisData/AnalysisData/User/Model/Role.cs +++ b/AnalysisData/AnalysisData/User/Model/Role.cs @@ -1,7 +1,7 @@ -namespace AnalysisData.UserManage.Model; - using System.ComponentModel.DataAnnotations; +namespace AnalysisData.User.Model; + public class Role { [Key] public int Id { get; set; } diff --git a/AnalysisData/AnalysisData/User/Model/User.cs b/AnalysisData/AnalysisData/User/Model/User.cs index 21cd1bc..6b728b5 100644 --- a/AnalysisData/AnalysisData/User/Model/User.cs +++ b/AnalysisData/AnalysisData/User/Model/User.cs @@ -1,8 +1,8 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using AnalysisData.EAV.Model; +using AnalysisData.Graph.Model.File; -namespace AnalysisData.UserManage.Model; +namespace AnalysisData.User.Model; public class User { diff --git a/AnalysisData/AnalysisData/User/Repository/RoleRepository/Abstraction/IRoleRepository.cs b/AnalysisData/AnalysisData/User/Repository/RoleRepository/Abstraction/IRoleRepository.cs index ce5c880..de3d3b7 100644 --- a/AnalysisData/AnalysisData/User/Repository/RoleRepository/Abstraction/IRoleRepository.cs +++ b/AnalysisData/AnalysisData/User/Repository/RoleRepository/Abstraction/IRoleRepository.cs @@ -1,6 +1,6 @@ -using AnalysisData.UserManage.Model; +using AnalysisData.User.Model; -namespace AnalysisData.Repository.RoleRepository.Abstraction; +namespace AnalysisData.User.Repository.RoleRepository.Abstraction; public interface IRoleRepository { diff --git a/AnalysisData/AnalysisData/User/Repository/RoleRepository/RoleRepository.cs b/AnalysisData/AnalysisData/User/Repository/RoleRepository/RoleRepository.cs index 218f0ef..0b5b830 100644 --- a/AnalysisData/AnalysisData/User/Repository/RoleRepository/RoleRepository.cs +++ b/AnalysisData/AnalysisData/User/Repository/RoleRepository/RoleRepository.cs @@ -1,9 +1,9 @@ using AnalysisData.Data; -using AnalysisData.Repository.RoleRepository.Abstraction; -using AnalysisData.UserManage.Model; +using AnalysisData.User.Model; +using AnalysisData.User.Repository.RoleRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.Repository.RoleRepository; +namespace AnalysisData.User.Repository.RoleRepository; public class RoleRepository : IRoleRepository { diff --git a/AnalysisData/AnalysisData/User/Repository/UserRepository/Abstraction/IUserRepository.cs b/AnalysisData/AnalysisData/User/Repository/UserRepository/Abstraction/IUserRepository.cs index dfd9be4..01bdc09 100644 --- a/AnalysisData/AnalysisData/User/Repository/UserRepository/Abstraction/IUserRepository.cs +++ b/AnalysisData/AnalysisData/User/Repository/UserRepository/Abstraction/IUserRepository.cs @@ -1,16 +1,14 @@ -using AnalysisData.UserManage.Model; - -namespace AnalysisData.Repository.UserRepository.Abstraction; +namespace AnalysisData.User.Repository.UserRepository.Abstraction; public interface IUserRepository { - Task GetUserByUsernameAsync(string userName); - Task GetUserByEmailAsync(string email); - Task GetUserByIdAsync(Guid id); - Task> GetAllUserPaginationAsync(int page, int limit); + Task GetUserByUsernameAsync(string userName); + Task GetUserByEmailAsync(string email); + Task GetUserByIdAsync(Guid id); + Task> GetAllUserPaginationAsync(int page, int limit); Task DeleteUserAsync(Guid id); - Task AddUserAsync(User user); - Task UpdateUserAsync(Guid id, User newUser); + Task AddUserAsync(Model.User user); + Task UpdateUserAsync(Guid id, Model.User newUser); Task GetUsersCountAsync(); - Task> GetTopUsersByUsernameSearchAsync(string username); + Task> GetTopUsersByUsernameSearchAsync(string username); } \ No newline at end of file diff --git a/AnalysisData/AnalysisData/User/Repository/UserRepository/UserRepository.cs b/AnalysisData/AnalysisData/User/Repository/UserRepository/UserRepository.cs index 9f886f1..62cee02 100644 --- a/AnalysisData/AnalysisData/User/Repository/UserRepository/UserRepository.cs +++ b/AnalysisData/AnalysisData/User/Repository/UserRepository/UserRepository.cs @@ -1,9 +1,8 @@ using AnalysisData.Data; -using AnalysisData.Repository.UserRepository.Abstraction; -using AnalysisData.UserManage.Model; +using AnalysisData.User.Repository.UserRepository.Abstraction; using Microsoft.EntityFrameworkCore; -namespace AnalysisData.Repository.UserRepository +namespace AnalysisData.User.Repository.UserRepository { public class UserRepository : IUserRepository { @@ -14,24 +13,24 @@ public UserRepository(ApplicationDbContext context) _context = context; } - public async Task GetUserByUsernameAsync(string userName) + public async Task GetUserByUsernameAsync(string userName) { return await _context.Users.Include(u => u.Role).FirstOrDefaultAsync(x => x.Username == userName); } - public async Task GetUserByEmailAsync(string email) + public async Task GetUserByEmailAsync(string email) { return await _context.Users.Include(u => u.Role).FirstOrDefaultAsync(x => x.Email == email); } - public async Task GetUserByIdAsync(Guid id) + public async Task GetUserByIdAsync(Guid id) { return await _context.Users.Include(u => u.Role).FirstOrDefaultAsync(x => x.Id == id); } - public async Task> GetAllUserPaginationAsync(int page, int limit) + public async Task> GetAllUserPaginationAsync(int page, int limit) { return await _context.Users.Include(u => u.Role).Skip((page) * limit).Take(limit).ToListAsync(); } @@ -50,14 +49,14 @@ public async Task DeleteUserAsync(Guid id) return true; } - public async Task AddUserAsync(User user) + public async Task AddUserAsync(Model.User user) { _context.Users.Add(user); await _context.SaveChangesAsync(); return true; } - public async Task UpdateUserAsync(Guid id, User newUser) + public async Task UpdateUserAsync(Guid id, Model.User newUser) { var user = await GetUserByIdAsync(id); newUser.Id = user.Id; @@ -66,7 +65,7 @@ public async Task UpdateUserAsync(Guid id, User newUser) return true; } - public async Task> GetTopUsersByUsernameSearchAsync(string username) + public async Task> GetTopUsersByUsernameSearchAsync(string username) { return await _context.Users.Include(u => u.Role) .Where(x => x.Username.Contains(username) && x.Role.RoleName != "dataanalyst").Take(10).ToListAsync(); diff --git a/AnalysisData/AnalysisData/User/Services/AdminService/Abstraction/IAdminRegisterService.cs b/AnalysisData/AnalysisData/User/Services/AdminService/Abstraction/IAdminRegisterService.cs index bb3b4b0..6c9adb3 100644 --- a/AnalysisData/AnalysisData/User/Services/AdminService/Abstraction/IAdminRegisterService.cs +++ b/AnalysisData/AnalysisData/User/Services/AdminService/Abstraction/IAdminRegisterService.cs @@ -1,6 +1,6 @@ -using AnalysisData.UserManage.RegisterModel; +using AnalysisData.User.UserDto.UserDto; -namespace AnalysisData.Services; +namespace AnalysisData.User.Services.AdminService.Abstraction; public interface IAdminRegisterService { diff --git a/AnalysisData/AnalysisData/User/Services/AdminService/Abstraction/IAdminService.cs b/AnalysisData/AnalysisData/User/Services/AdminService/Abstraction/IAdminService.cs index 4c181f2..6e77e06 100644 --- a/AnalysisData/AnalysisData/User/Services/AdminService/Abstraction/IAdminService.cs +++ b/AnalysisData/AnalysisData/User/Services/AdminService/Abstraction/IAdminService.cs @@ -1,10 +1,6 @@ -using AnalysisData.UserManage.Model; -using AnalysisData.UserManage.RegisterModel; -using AnalysisData.UserManage.RolePaginationModel; -using AnalysisData.UserManage.UpdateModel; -using AnalysisData.UserManage.UserPaginationModel; +using AnalysisData.User.UserDto.UserDto; -namespace AnalysisData.Services.Abstraction; +namespace AnalysisData.User.Services.AdminService.Abstraction; public interface IAdminService { diff --git a/AnalysisData/AnalysisData/User/Services/AdminService/AdminRegisterService.cs b/AnalysisData/AnalysisData/User/Services/AdminService/AdminRegisterService.cs index d18b954..8f58513 100644 --- a/AnalysisData/AnalysisData/User/Services/AdminService/AdminRegisterService.cs +++ b/AnalysisData/AnalysisData/User/Services/AdminService/AdminRegisterService.cs @@ -1,16 +1,13 @@ -using System.Security.Cryptography; -using System.Text; -using AnalysisData.Exception; -using AnalysisData.JwtService.abstractions; -using AnalysisData.Repository.RoleRepository.Abstraction; -using AnalysisData.Repository.UserRepository.Abstraction; -using AnalysisData.Services.Abstraction; -using AnalysisData.Services.S3FileStorageService; -using AnalysisData.Services.SecurityPasswordService.Abstraction; -using AnalysisData.UserManage.Model; -using AnalysisData.UserManage.RegisterModel; +using AnalysisData.Exception.UserException; +using AnalysisData.User.Model; +using AnalysisData.User.Repository.RoleRepository.Abstraction; +using AnalysisData.User.Repository.UserRepository.Abstraction; +using AnalysisData.User.Services.AdminService.Abstraction; +using AnalysisData.User.Services.SecurityPasswordService.Abstraction; +using AnalysisData.User.Services.ValidationService.Abstraction; +using AnalysisData.User.UserDto.UserDto; -namespace AnalysisData.Services; +namespace AnalysisData.User.Services.AdminService; public class AdminRegisterService : IAdminRegisterService { @@ -32,35 +29,49 @@ public AdminRegisterService(IUserRepository userRepository, IValidationService v public async Task RegisterByAdminAsync(UserRegisterDto userRegisterDto) { var roleCheck = userRegisterDto.RoleName.ToLower(); + var existingRole = await CheckExistenceRoleAsync(roleCheck); + await ValidateUserRegistrationDataAsync(userRegisterDto); + var user = await MakeUser(userRegisterDto, existingRole); + await _userRepository.AddUserAsync(user); + } + + private async Task ValidateUserRegistrationDataAsync(UserRegisterDto userRegisterDto) + { + await CheckForDuplicateUserAsync(userRegisterDto); + ValidateInputFormat(userRegisterDto); + if (userRegisterDto.Password != userRegisterDto.ConfirmPassword) + throw new PasswordMismatchException(); + } + + private void ValidateInputFormat(UserRegisterDto userRegisterDto) + { + _validationService.EmailCheck(userRegisterDto.Email); + _validationService.PasswordCheck(userRegisterDto.Password); + _validationService.PhoneNumberCheck(userRegisterDto.PhoneNumber); + } + + private async Task CheckExistenceRoleAsync(string roleCheck) + { var existingRole = await _roleRepository.GetRoleByNameAsync(roleCheck); if (existingRole == null) { throw new RoleNotFoundException(); } + return existingRole; + } + + private async Task CheckForDuplicateUserAsync(UserRegisterDto userRegisterDto) + { var existingUserByEmail = await _userRepository.GetUserByEmailAsync(userRegisterDto.Email); var existingUserByUsername = await _userRepository.GetUserByUsernameAsync(userRegisterDto.Username); - if (existingUserByEmail != null && existingUserByUsername != null) + if (existingUserByEmail != null || existingUserByUsername != null) throw new DuplicateUserException(); - _validationService.EmailCheck(userRegisterDto.Email); - _validationService.PasswordCheck(userRegisterDto.Password); - if (userRegisterDto.Password != userRegisterDto.ConfirmPassword) - { - throw new PasswordMismatchException(); - } - - _validationService.PhoneNumberCheck(userRegisterDto.PhoneNumber); - if (userRegisterDto.Password != userRegisterDto.ConfirmPassword) - throw new PasswordMismatchException(); - - - var user = await MakeUser(userRegisterDto, existingRole); - await _userRepository.AddUserAsync(user); } - private async Task MakeUser(UserRegisterDto userRegisterDto, Role role) + private async Task MakeUser(UserRegisterDto userRegisterDto, Role role) { - var user = new User + var user = new Model.User { Username = userRegisterDto.Username, Password = _passwordHasher.HashPassword(userRegisterDto.Password), diff --git a/AnalysisData/AnalysisData/User/Services/AdminService/AdminService.cs b/AnalysisData/AnalysisData/User/Services/AdminService/AdminService.cs index 1b5ae2b..65f728b 100644 --- a/AnalysisData/AnalysisData/User/Services/AdminService/AdminService.cs +++ b/AnalysisData/AnalysisData/User/Services/AdminService/AdminService.cs @@ -1,17 +1,12 @@ -using System.Security.Cryptography; -using System.Text; -using AnalysisData.Exception; -using AnalysisData.JwtService.abstractions; -using AnalysisData.Repository.RoleRepository.Abstraction; -using AnalysisData.Repository.UserRepository.Abstraction; -using AnalysisData.Services.Abstraction; -using AnalysisData.UserManage.Model; -using AnalysisData.UserManage.RegisterModel; -using AnalysisData.UserManage.RolePaginationModel; -using AnalysisData.UserManage.UpdateModel; -using AnalysisData.UserManage.UserPaginationModel; +using AnalysisData.Exception.UserException; +using AnalysisData.User.JwtService.abstractions; +using AnalysisData.User.Repository.RoleRepository.Abstraction; +using AnalysisData.User.Repository.UserRepository.Abstraction; +using AnalysisData.User.Services.AdminService.Abstraction; +using AnalysisData.User.Services.ValidationService.Abstraction; +using AnalysisData.User.UserDto.UserDto; -namespace AnalysisData.Services; +namespace AnalysisData.User.Services.AdminService; public class AdminService : IAdminService { @@ -32,14 +27,27 @@ public AdminService(IUserRepository userRepository, IValidationService validatio public async Task UpdateUserInformationByAdminAsync(Guid id, UpdateAdminDto updateAdminDto) { var user = await _userRepository.GetUserByIdAsync(id); + + await ValidateUserInformation(user, updateAdminDto); + _validationService.EmailCheck(updateAdminDto.Email); + _validationService.PhoneNumberCheck(updateAdminDto.PhoneNumber); + await CheckExistenceOfRole(user,updateAdminDto); + + await SetUpdatedInformation(user, updateAdminDto); + await _jwtService.UpdateUserCookie(user.Username, false); + } + + private async Task ValidateUserInformation(Model.User user,UpdateAdminDto updateAdminDto) + { var checkUsername = await _userRepository.GetUserByUsernameAsync(updateAdminDto.Username); var checkEmail = await _userRepository.GetUserByEmailAsync(updateAdminDto.Email); if ((checkUsername != null && !user.Equals(checkUsername)) || (checkEmail != null && !user.Equals(checkEmail))) throw new DuplicateUserException(); + } - _validationService.EmailCheck(updateAdminDto.Email); - _validationService.PhoneNumberCheck(updateAdminDto.PhoneNumber); + private async Task CheckExistenceOfRole(Model.User user,UpdateAdminDto updateAdminDto) + { var role = await _roleRepository.GetRoleByNameAsync(updateAdminDto.RoleName); if (role == null) { @@ -50,7 +58,7 @@ public async Task UpdateUserInformationByAdminAsync(Guid id, UpdateAdminDto upda await _jwtService.UpdateUserCookie(user.Username, false); } - private async Task SetUpdatedInformation(User user, UpdateAdminDto updateAdminDto) + private async Task SetUpdatedInformation(Model.User user, UpdateAdminDto updateAdminDto) { user.FirstName = updateAdminDto.FirstName; user.LastName = updateAdminDto.LastName; @@ -60,6 +68,7 @@ private async Task SetUpdatedInformation(User user, UpdateAdminDto updateAdminDt user.Role.RoleName = updateAdminDto.RoleName; await _userRepository.UpdateUserAsync(user.Id, user); } + public async Task DeleteUserAsync(Guid id) { diff --git a/AnalysisData/AnalysisData/User/Services/PemissionService/Abstraction/IPermissionService.cs b/AnalysisData/AnalysisData/User/Services/PermissionService/Abstraction/IPermissionService.cs similarity index 68% rename from AnalysisData/AnalysisData/User/Services/PemissionService/Abstraction/IPermissionService.cs rename to AnalysisData/AnalysisData/User/Services/PermissionService/Abstraction/IPermissionService.cs index b2ce766..cff815d 100644 --- a/AnalysisData/AnalysisData/User/Services/PemissionService/Abstraction/IPermissionService.cs +++ b/AnalysisData/AnalysisData/User/Services/PermissionService/Abstraction/IPermissionService.cs @@ -1,6 +1,6 @@ using System.Security.Claims; -namespace AnalysisData.Services.Abstraction; +namespace AnalysisData.User.Services.PermissionService.Abstraction; public interface IPermissionService { diff --git a/AnalysisData/AnalysisData/User/Services/PemissionService/PermissionService.cs b/AnalysisData/AnalysisData/User/Services/PermissionService/PermissionService.cs similarity index 91% rename from AnalysisData/AnalysisData/User/Services/PemissionService/PermissionService.cs rename to AnalysisData/AnalysisData/User/Services/PermissionService/PermissionService.cs index 8147a16..eefde1f 100644 --- a/AnalysisData/AnalysisData/User/Services/PemissionService/PermissionService.cs +++ b/AnalysisData/AnalysisData/User/Services/PermissionService/PermissionService.cs @@ -1,12 +1,12 @@ using System.Reflection; using System.Security.Claims; -using AnalysisData.Exception; -using AnalysisData.Repository.RoleRepository.Abstraction; -using AnalysisData.Services.Abstraction; +using AnalysisData.Exception.UserException; +using AnalysisData.User.Repository.RoleRepository.Abstraction; +using AnalysisData.User.Services.PermissionService.Abstraction; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -namespace AnalysisData.Services; +namespace AnalysisData.User.Services.PermissionService; public class PermissionService : IPermissionService { diff --git a/AnalysisData/AnalysisData/User/Services/RoleService/Abstraction/IRoleManagementService.cs b/AnalysisData/AnalysisData/User/Services/RoleService/Abstraction/IRoleManagementService.cs index a6d1f23..a10239e 100644 --- a/AnalysisData/AnalysisData/User/Services/RoleService/Abstraction/IRoleManagementService.cs +++ b/AnalysisData/AnalysisData/User/Services/RoleService/Abstraction/IRoleManagementService.cs @@ -1,6 +1,6 @@ -using AnalysisData.UserManage.RolePaginationModel; +using AnalysisData.User.UserDto.RoleDto; -namespace AnalysisData.Services; +namespace AnalysisData.User.Services.RoleService.Abstraction; public interface IRoleManagementService { diff --git a/AnalysisData/AnalysisData/User/Services/RoleService/RoleManagementService.cs b/AnalysisData/AnalysisData/User/Services/RoleService/RoleManagementService.cs index c940539..8799059 100644 --- a/AnalysisData/AnalysisData/User/Services/RoleService/RoleManagementService.cs +++ b/AnalysisData/AnalysisData/User/Services/RoleService/RoleManagementService.cs @@ -1,12 +1,10 @@ -using AnalysisData.Exception; -using AnalysisData.JwtService.abstractions; -using AnalysisData.Repository.RoleRepository.Abstraction; -using AnalysisData.Repository.UserRepository.Abstraction; -using AnalysisData.Services.Abstraction; -using AnalysisData.UserManage.Model; -using AnalysisData.UserManage.RolePaginationModel; - -namespace AnalysisData.Services; +using AnalysisData.Exception.UserException; +using AnalysisData.User.Model; +using AnalysisData.User.Repository.RoleRepository.Abstraction; +using AnalysisData.User.Services.RoleService.Abstraction; +using AnalysisData.User.UserDto.RoleDto; + +namespace AnalysisData.User.Services.RoleService; public class RoleManagementService : IRoleManagementService { diff --git a/AnalysisData/AnalysisData/User/Services/S3FileStorageService/Abstraction/IS3FileStorageService.cs b/AnalysisData/AnalysisData/User/Services/S3FileStorageService/Abstraction/IS3FileStorageService.cs index 03dd68a..7bf7fc4 100644 --- a/AnalysisData/AnalysisData/User/Services/S3FileStorageService/Abstraction/IS3FileStorageService.cs +++ b/AnalysisData/AnalysisData/User/Services/S3FileStorageService/Abstraction/IS3FileStorageService.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Services.S3FileStorageService; +namespace AnalysisData.User.Services.S3FileStorageService.Abstraction; public interface IS3FileStorageService { diff --git a/AnalysisData/AnalysisData/User/Services/S3FileStorageService/S3FileStorageService.cs b/AnalysisData/AnalysisData/User/Services/S3FileStorageService/S3FileStorageService.cs index 6e68dd2..e448197 100644 --- a/AnalysisData/AnalysisData/User/Services/S3FileStorageService/S3FileStorageService.cs +++ b/AnalysisData/AnalysisData/User/Services/S3FileStorageService/S3FileStorageService.cs @@ -1,8 +1,9 @@ using Amazon; using Amazon.S3; using Amazon.S3.Model; +using AnalysisData.User.Services.S3FileStorageService.Abstraction; -namespace AnalysisData.Services.S3FileStorageService; +namespace AnalysisData.User.Services.S3FileStorageService; public class S3FileStorageService : IS3FileStorageService { diff --git a/AnalysisData/AnalysisData/User/Services/SecurityPasswordService/Abstraction/IPasswordHasher.cs b/AnalysisData/AnalysisData/User/Services/SecurityPasswordService/Abstraction/IPasswordHasher.cs index c9ad3fb..cc0c016 100644 --- a/AnalysisData/AnalysisData/User/Services/SecurityPasswordService/Abstraction/IPasswordHasher.cs +++ b/AnalysisData/AnalysisData/User/Services/SecurityPasswordService/Abstraction/IPasswordHasher.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Services.SecurityPasswordService.Abstraction; +namespace AnalysisData.User.Services.SecurityPasswordService.Abstraction; public interface IPasswordHasher { diff --git a/AnalysisData/AnalysisData/User/Services/SecurityPasswordService/PasswordHasher.cs b/AnalysisData/AnalysisData/User/Services/SecurityPasswordService/PasswordHasher.cs index 87d9358..9fbfb8e 100644 --- a/AnalysisData/AnalysisData/User/Services/SecurityPasswordService/PasswordHasher.cs +++ b/AnalysisData/AnalysisData/User/Services/SecurityPasswordService/PasswordHasher.cs @@ -1,8 +1,8 @@ using System.Security.Cryptography; using System.Text; -using AnalysisData.Services.SecurityPasswordService.Abstraction; +using AnalysisData.User.Services.SecurityPasswordService.Abstraction; -namespace AnalysisData.Services.SecurityPasswordService; +namespace AnalysisData.User.Services.SecurityPasswordService; public class PasswordHasher : IPasswordHasher { diff --git a/AnalysisData/AnalysisData/User/Services/UserService/Abstraction/IUploadImageService.cs b/AnalysisData/AnalysisData/User/Services/UserService/Abstraction/IUploadImageService.cs index aeffbb5..978c92d 100644 --- a/AnalysisData/AnalysisData/User/Services/UserService/Abstraction/IUploadImageService.cs +++ b/AnalysisData/AnalysisData/User/Services/UserService/Abstraction/IUploadImageService.cs @@ -1,6 +1,6 @@ using System.Security.Claims; -namespace AnalysisData.Services.Abstraction; +namespace AnalysisData.User.Services.UserService.Abstraction; public interface IUploadImageService { diff --git a/AnalysisData/AnalysisData/User/Services/UserService/Abstraction/IUserService.cs b/AnalysisData/AnalysisData/User/Services/UserService/Abstraction/IUserService.cs index 8a03629..2260af9 100644 --- a/AnalysisData/AnalysisData/User/Services/UserService/Abstraction/IUserService.cs +++ b/AnalysisData/AnalysisData/User/Services/UserService/Abstraction/IUserService.cs @@ -1,15 +1,12 @@ using System.Security.Claims; -using AnalysisData.UserManage.LoginModel; -using AnalysisData.UserManage.Model; -using AnalysisData.UserManage.UpdateModel; -using AnalysisData.UserManage.UserPaginationModel; +using AnalysisData.User.UserDto.UserDto; -namespace AnalysisData.Services.Abstraction; +namespace AnalysisData.User.Services.UserService.Abstraction; public interface IUserService { - Task LoginAsync(UserLoginDto userLoginDto); - Task GetUserAsync(ClaimsPrincipal userClaim); + Task LoginAsync(UserLoginDto userLoginDto); + Task GetUserAsync(ClaimsPrincipal userClaim); Task ResetPasswordAsync(ClaimsPrincipal userClaim, string password, string confirmPassword); Task UpdateUserInformationAsync(ClaimsPrincipal userClaim, UpdateUserDto updateUserDto); Task NewPasswordAsync(ClaimsPrincipal userClaim, string oldPassword, string password, string confirmPassword); diff --git a/AnalysisData/AnalysisData/User/Services/UserService/UploadImageService.cs b/AnalysisData/AnalysisData/User/Services/UserService/UploadImageService.cs index 21b2326..434b97b 100644 --- a/AnalysisData/AnalysisData/User/Services/UserService/UploadImageService.cs +++ b/AnalysisData/AnalysisData/User/Services/UserService/UploadImageService.cs @@ -1,10 +1,10 @@ using System.Security.Claims; -using AnalysisData.Exception; -using AnalysisData.Repository.UserRepository.Abstraction; -using AnalysisData.Services.Abstraction; -using AnalysisData.Services.S3FileStorageService; +using AnalysisData.Exception.UserException; +using AnalysisData.User.Repository.UserRepository.Abstraction; +using AnalysisData.User.Services.S3FileStorageService.Abstraction; +using AnalysisData.User.Services.UserService.Abstraction; -namespace AnalysisData.Services; +namespace AnalysisData.User.Services.UserService; public class UploadImageService : IUploadImageService { diff --git a/AnalysisData/AnalysisData/User/Services/UserService/UserService.cs b/AnalysisData/AnalysisData/User/Services/UserService/UserService.cs index f9ee68c..f367339 100644 --- a/AnalysisData/AnalysisData/User/Services/UserService/UserService.cs +++ b/AnalysisData/AnalysisData/User/Services/UserService/UserService.cs @@ -1,18 +1,14 @@ using System.Security.Claims; -using System.Security.Cryptography; -using System.Text; -using AnalysisData.CookieService.abstractions; -using AnalysisData.Exception; -using AnalysisData.JwtService.abstractions; -using AnalysisData.Repository.UserRepository.Abstraction; -using AnalysisData.Services.Abstraction; -using AnalysisData.Services.S3FileStorageService; -using AnalysisData.Services.SecurityPasswordService.Abstraction; -using AnalysisData.UserManage.LoginModel; -using AnalysisData.UserManage.Model; -using AnalysisData.UserManage.UpdateModel; - -namespace AnalysisData.Services; +using AnalysisData.Exception.UserException; +using AnalysisData.User.CookieService.abstractions; +using AnalysisData.User.JwtService.abstractions; +using AnalysisData.User.Repository.UserRepository.Abstraction; +using AnalysisData.User.Services.SecurityPasswordService.Abstraction; +using AnalysisData.User.Services.UserService.Abstraction; +using AnalysisData.User.Services.ValidationService.Abstraction; +using AnalysisData.User.UserDto.UserDto; + +namespace AnalysisData.User.Services.UserService; public class UserService : IUserService { @@ -79,7 +75,7 @@ public async Task NewPasswordAsync(ClaimsPrincipal userClaim, string oldPa return true; } - public async Task LoginAsync(UserLoginDto userLoginDto) + public async Task LoginAsync(UserLoginDto userLoginDto) { var user = await _userRepository.GetUserByUsernameAsync(userLoginDto.userName); if (user == null) @@ -97,7 +93,7 @@ public async Task LoginAsync(UserLoginDto userLoginDto) return user; } - public async Task GetUserAsync(ClaimsPrincipal userClaim) + public async Task GetUserAsync(ClaimsPrincipal userClaim) { var userName = userClaim.FindFirstValue("username"); var user = await _userRepository.GetUserByUsernameAsync(userName); @@ -125,7 +121,7 @@ public async Task UpdateUserInformationAsync(ClaimsPrincipal userClaim, Up return true; } - private async Task ReplaceUserDetails(User user, UpdateUserDto updateUserDto) + private async Task ReplaceUserDetails(Model.User user, UpdateUserDto updateUserDto) { user.FirstName = updateUserDto.FirstName; user.LastName = updateUserDto.LastName; diff --git a/AnalysisData/AnalysisData/User/Services/ValidationService/Abstraction/IValidationService.cs b/AnalysisData/AnalysisData/User/Services/ValidationService/Abstraction/IValidationService.cs index c3a8ebd..4d09db1 100644 --- a/AnalysisData/AnalysisData/User/Services/ValidationService/Abstraction/IValidationService.cs +++ b/AnalysisData/AnalysisData/User/Services/ValidationService/Abstraction/IValidationService.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.Services.Abstraction; +namespace AnalysisData.User.Services.ValidationService.Abstraction; public interface IValidationService { diff --git a/AnalysisData/AnalysisData/User/Services/ValidationService/ValidationService.cs b/AnalysisData/AnalysisData/User/Services/ValidationService/ValidationService.cs index 426e216..8c3218d 100644 --- a/AnalysisData/AnalysisData/User/Services/ValidationService/ValidationService.cs +++ b/AnalysisData/AnalysisData/User/Services/ValidationService/ValidationService.cs @@ -1,9 +1,9 @@ using System.Text.RegularExpressions; -using AnalysisData.Exception; -using AnalysisData.Services.Abstraction; -using AnalysisData.UserManage.Model; +using AnalysisData.Exception.UserException; +using AnalysisData.User.Model; +using AnalysisData.User.Services.ValidationService.Abstraction; -namespace AnalysisData.Services; +namespace AnalysisData.User.Services.ValidationService; public class ValidationService : IValidationService { diff --git a/AnalysisData/AnalysisData/User/UserDto/PasswordDto/NewPasswordDto.cs b/AnalysisData/AnalysisData/User/UserDto/PasswordDto/NewPasswordDto.cs index 4d7d845..7894240 100644 --- a/AnalysisData/AnalysisData/User/UserDto/PasswordDto/NewPasswordDto.cs +++ b/AnalysisData/AnalysisData/User/UserDto/PasswordDto/NewPasswordDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserManage.NewPasswordModel; +namespace AnalysisData.User.UserDto.PasswordDto; public class NewPasswordDto { diff --git a/AnalysisData/AnalysisData/User/UserDto/PasswordDto/ResetPasswordDto.cs b/AnalysisData/AnalysisData/User/UserDto/PasswordDto/ResetPasswordDto.cs index e15ee4c..f0c31ee 100644 --- a/AnalysisData/AnalysisData/User/UserDto/PasswordDto/ResetPasswordDto.cs +++ b/AnalysisData/AnalysisData/User/UserDto/PasswordDto/ResetPasswordDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserManage.ResetPasswordModel; +namespace AnalysisData.User.UserDto.PasswordDto; public class ResetPasswordDto { diff --git a/AnalysisData/AnalysisData/User/UserDto/RoleDto/AddRoleDto.cs b/AnalysisData/AnalysisData/User/UserDto/RoleDto/AddRoleDto.cs index 9fb54bc..4f6b5cd 100644 --- a/AnalysisData/AnalysisData/User/UserDto/RoleDto/AddRoleDto.cs +++ b/AnalysisData/AnalysisData/User/UserDto/RoleDto/AddRoleDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserManage.RolePaginationModel; +namespace AnalysisData.User.UserDto.RoleDto; public class AddRoleDto { diff --git a/AnalysisData/AnalysisData/User/UserDto/RoleDto/RolePaginationDto.cs b/AnalysisData/AnalysisData/User/UserDto/RoleDto/RolePaginationDto.cs index abd6e93..c1c50c1 100644 --- a/AnalysisData/AnalysisData/User/UserDto/RoleDto/RolePaginationDto.cs +++ b/AnalysisData/AnalysisData/User/UserDto/RoleDto/RolePaginationDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserManage.RolePaginationModel; +namespace AnalysisData.User.UserDto.RoleDto; public class RolePaginationDto { diff --git a/AnalysisData/AnalysisData/User/UserDto/UserDto/GetUserInformationDto.cs b/AnalysisData/AnalysisData/User/UserDto/UserDto/GetUserInformationDto.cs index f78398f..d673a57 100644 --- a/AnalysisData/AnalysisData/User/UserDto/UserDto/GetUserInformationDto.cs +++ b/AnalysisData/AnalysisData/User/UserDto/UserDto/GetUserInformationDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserDto.UserDto; +namespace AnalysisData.User.UserDto.UserDto; public class GetUserInformationDto { diff --git a/AnalysisData/AnalysisData/User/UserDto/UserDto/UpdateAdminDto.cs b/AnalysisData/AnalysisData/User/UserDto/UserDto/UpdateAdminDto.cs index 8b7c408..8432093 100644 --- a/AnalysisData/AnalysisData/User/UserDto/UserDto/UpdateAdminDto.cs +++ b/AnalysisData/AnalysisData/User/UserDto/UserDto/UpdateAdminDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserManage.UpdateModel; +namespace AnalysisData.User.UserDto.UserDto; public class UpdateAdminDto { diff --git a/AnalysisData/AnalysisData/User/UserDto/UserDto/UpdateUserDto.cs b/AnalysisData/AnalysisData/User/UserDto/UserDto/UpdateUserDto.cs index 7658d4b..4bf17a7 100644 --- a/AnalysisData/AnalysisData/User/UserDto/UserDto/UpdateUserDto.cs +++ b/AnalysisData/AnalysisData/User/UserDto/UserDto/UpdateUserDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserManage.UpdateModel; +namespace AnalysisData.User.UserDto.UserDto; public class UpdateUserDto { diff --git a/AnalysisData/AnalysisData/User/UserDto/UserDto/UserLoginDto.cs b/AnalysisData/AnalysisData/User/UserDto/UserDto/UserLoginDto.cs index 60e2bc2..872a10f 100644 --- a/AnalysisData/AnalysisData/User/UserDto/UserDto/UserLoginDto.cs +++ b/AnalysisData/AnalysisData/User/UserDto/UserDto/UserLoginDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserManage.LoginModel; +namespace AnalysisData.User.UserDto.UserDto; public class UserLoginDto { diff --git a/AnalysisData/AnalysisData/User/UserDto/UserDto/UserPaginationDto.cs b/AnalysisData/AnalysisData/User/UserDto/UserDto/UserPaginationDto.cs index 24e2722..11b696a 100644 --- a/AnalysisData/AnalysisData/User/UserDto/UserDto/UserPaginationDto.cs +++ b/AnalysisData/AnalysisData/User/UserDto/UserDto/UserPaginationDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserManage.UserPaginationModel; +namespace AnalysisData.User.UserDto.UserDto; public class UserPaginationDto { diff --git a/AnalysisData/AnalysisData/User/UserDto/UserDto/UserRegisterDto.cs b/AnalysisData/AnalysisData/User/UserDto/UserDto/UserRegisterDto.cs index 33592dd..c6a8cab 100644 --- a/AnalysisData/AnalysisData/User/UserDto/UserDto/UserRegisterDto.cs +++ b/AnalysisData/AnalysisData/User/UserDto/UserDto/UserRegisterDto.cs @@ -1,4 +1,4 @@ -namespace AnalysisData.UserManage.RegisterModel; +namespace AnalysisData.User.UserDto.UserDto; public class UserRegisterDto { diff --git a/AnalysisData/TestProject/Repository/RoleRepository/RoleRepositoryTests.cs b/AnalysisData/TestProject/Repository/RoleRepository/RoleRepositoryTests.cs deleted file mode 100644 index 5d5a8a0..0000000 --- a/AnalysisData/TestProject/Repository/RoleRepository/RoleRepositoryTests.cs +++ /dev/null @@ -1,89 +0,0 @@ -// using AnalysisData.Data; -// using AnalysisData.UserManage.Model; -// using Microsoft.EntityFrameworkCore; -// -// namespace TestProject.Repository.RoleRepository; -// -// public class RoleRepositoryTests -// { -// private readonly DbContextOptions _options; -// private readonly ApplicationDbContext _context; -// private readonly AnalysisData.Repository.RoleRepository.RoleRepository _sut; -// -// public RoleRepositoryTests() -// { -// _options = new DbContextOptionsBuilder().UseInMemoryDatabase("TestDatabase").Options; -// _context = new ApplicationDbContext(_options); -// _sut = new AnalysisData.Repository.RoleRepository.RoleRepository(_context); -// } -// -// [Fact] -// public async Task GetRole_ShouldReturnsRole_WhenRoleExists() -// { -// // Arrange -// var role = new Role { Id = 1, RoleName = "Admin" }; -// _context.Roles.Add(role); -// await _context.SaveChangesAsync(); -// -// // Act -// var result = await _sut.GetRoleById(1); -// -// // Assert -// Assert.NotNull(result); -// Assert.Equal("Admin", result.RoleName); -// _context.Roles.Remove(role); -// _context.SaveChangesAsync(); -// } -// -// [Fact] -// public void AddRole_ShouldAddsRoleToDatabase_Whenever() -// { -// // Arrange -// var role = new Role { Id = 1, RoleName = "Admin" }; -// -// // Act -// _sut.AddRole(role); -// -// // Assert -// Assert.Equal(1, _context.Roles.Count()); -// Assert.Contains(_context.Roles, r => r.RoleName == "Admin"); -// _context.Roles.Remove(role); -// _context.SaveChangesAsync(); -// } -// -// [Fact] -// public void DeleteRole_ShouldRemovesRole_WhenRoleExists() -// { -// // Arrange -// var role = new Role { Id = 1, RoleName = "Admin" }; -// _context.Roles.Add(role); -// _context.SaveChanges(); -// -// // Act -// var result = _sut.DeleteRole("Admin"); -// // Assert -// Assert.True(result); -// Assert.Equal(0, _context.Roles.Count()); -// Assert.DoesNotContain(_context.Roles, r => r.Id == 1); -// _context.Roles.Remove(role); -// _context.SaveChangesAsync(); -// } -// -// [Fact] -// public void DeleteRole_ShouldReturnsFalse_WhenRoleDoesNotExist() -// { -// // Arrange -// var role = new Role { Id = 1, RoleName = "Editor" }; -// _context.Roles.Add(role); -// _context.SaveChanges(); -// -// // Act -// var result = _sut.DeleteRole("admin"); -// -// // Assert -// Assert.False(result); -// Assert.Equal(1, _context.Roles.Count()); -// _context.Roles.Remove(role); -// _context.SaveChangesAsync(); -// } -// } \ No newline at end of file diff --git a/AnalysisData/TestProject/Repository/UserRepository/UserRepositoryTests.cs b/AnalysisData/TestProject/Repository/UserRepository/UserRepositoryTests.cs deleted file mode 100644 index f1a0fc3..0000000 --- a/AnalysisData/TestProject/Repository/UserRepository/UserRepositoryTests.cs +++ /dev/null @@ -1,115 +0,0 @@ -// using AnalysisData.Data; -// using AnalysisData.UserManage.Model; -// using Microsoft.EntityFrameworkCore; -// -// namespace TestProject.Repository.UserRepository; -// -// public class UserRepositoryTests -// { -// private readonly DbContextOptions _options; -// private readonly ApplicationDbContext _context; -// private readonly AnalysisData.Repository.UserRepository.UserRepository _sut; -// -// public UserRepositoryTests() -// { -// _options = new DbContextOptionsBuilder().UseInMemoryDatabase("TestDatabase").Options; -// _context = new ApplicationDbContext(_options); -// _sut = new AnalysisData.Repository.UserRepository.UserRepository(_context); -// } -// // -// // [Fact] -// // public async Task GetUser_ShouldReturnsUser_WhenUserExists() -// // { -// // // Arrange -// // var user = new User { Id = 1, Username = "user1", Password = "pass1", Email = "mahdijm.bb@gmail.com", FirstName = "mahdi", LastName = "jafari", PhoneNumber = "09162390873" }; -// // _context.Users.Add(user); -// // await _context.SaveChangesAsync(); -// // -// // // Act -// // var result = await _sut.GetUser("user1"); -// // -// // // Assert -// // Assert.Equal("user1", result.Username); -// // _context.Users.Remove(user); -// // await _context.SaveChangesAsync(); -// // } -// -// [Fact] -// public async Task GetUser_ShouldReturnsNull_WhenUserDoesNotExist() -// { -// // Arrange -// -// // Act -// var result = await _sut.GetUser("NoOne"); -// -// // Assert -// Assert.Null(result); -// } -// -// // [Fact] -// // public async Task GetAllUser_ShouldReturnsAllUsers_Whenever() -// // { -// // _context.Users.Add( -// // new User { Id = 1, Username = "user1", Password = "pass1" , Email = "mahdijm.bb@gmail.com", FirstName = "mahdi", LastName = "jafari", PhoneNumber = "09162390873" } -// // ); -// // _context.Users.Add( -// // new User { Id = 2, Username = "user2", Password = "pass2" , Email = "mahdijm.bb2@gmail.com", FirstName = "mahdi2", LastName = "jafari2", PhoneNumber = "09162390872"} -// // ); -// // await _context.SaveChangesAsync(); -// // -// // // Act -// // var result = await _sut.GetAllUser(); -// // -// // // Assert -// // Assert.Equal(2, result.Count); -// // _context.Users.Remove(result.ElementAt(0)); -// // _context.Users.Remove(result.ElementAt(1)); -// // await _context.SaveChangesAsync(); -// // } -// -// [Fact] -// public void DeleteUser_RemovesUser_WhenUserExists() -// { -// // Arrange -// var user = new User { Id = 1, Username = "user1", Password = "pass1" , Email = "mahdijm.bb@gmail.com", FirstName = "mahdi", LastName = "jafari", PhoneNumber = "09162390873"}; -// _context.Users.Add(user); -// _context.SaveChanges(); -// -// // Act -// var result = _sut.DeleteUser("user1"); -// -// // Assert -// Assert.True(result); -// Assert.Equal(0, _context.Users.Count()); -// } -// -// [Fact] -// public void DeleteUser_ReturnsFalse_WhenUserDoesNotExist() -// { -// // Arrange -// -// // Act -// var result = _sut.DeleteUser("NoOne"); -// -// // Assert -// Assert.False(result); -// } -// -// [Fact] -// public void AddUser_ShouldAddsUserToDatabase_Whenever() -// { -// // Arrange -// var user = new User { Id = 1, Username = "user1", Password = "pass1" , Email = "mahdijm.bb@gmail.com", FirstName = "mahdi", LastName = "jafari", PhoneNumber = "09162390873"}; -// -// // Act -// _sut.AddUser(user); -// -// // Assert -// Assert.Equal(1, _context.Users.Count()); -// Assert.Contains(_context.Users, u => u is { Username: "user1", Password: "pass1" }); -// _context.Users.Remove(user); -// _context.SaveChangesAsync(); -// } -// -// -// } \ No newline at end of file diff --git a/AnalysisData/TestProject/TestProject.csproj b/AnalysisData/TestProject/TestProject.csproj index 1eb8f6e..6351c55 100644 --- a/AnalysisData/TestProject/TestProject.csproj +++ b/AnalysisData/TestProject/TestProject.csproj @@ -13,7 +13,14 @@ + + + + + + + diff --git a/AnalysisData/TestProject/User/Repository/RoleRepository/RoleRepositoryTests.cs b/AnalysisData/TestProject/User/Repository/RoleRepository/RoleRepositoryTests.cs new file mode 100644 index 0000000..545ffde --- /dev/null +++ b/AnalysisData/TestProject/User/Repository/RoleRepository/RoleRepositoryTests.cs @@ -0,0 +1,254 @@ +using System.Linq; +using System.Threading.Tasks; +using AnalysisData.Data; +using AnalysisData.User.Model; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace TestProject.User.Repository.RoleRepository; + +public class RoleRepositoryTests +{ + private readonly AnalysisData.User.Repository.RoleRepository.RoleRepository _sut; + private readonly ServiceProvider _serviceProvider; + + public RoleRepositoryTests() + { + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .Options; + + var serviceCollection = new ServiceCollection(); + serviceCollection.AddScoped(_ => new ApplicationDbContext(options)); + _serviceProvider = serviceCollection.BuildServiceProvider(); + + _sut = new AnalysisData.User.Repository.RoleRepository.RoleRepository(CreateDbContext()); + } + + private ApplicationDbContext CreateDbContext() + { + return _serviceProvider.GetRequiredService(); + } + + [Fact] + public async Task GetRoleByIdAsync_ShouldReturnRoleWithInputId_WhenRoleExists() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }; + context.Roles.Add(role); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetRoleByIdAsync(1); + + // Assert + Assert.NotNull(result); + Assert.Equal("Admin", result.RoleName); + } + + [Fact] + public async Task GetRoleByIdAsync_ShouldReturnNull_WhenRoleDoesNotExist() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }; + context.Roles.Add(role); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetRoleByIdAsync(2); + + // Assert + Assert.Null(result); + } + + [Fact] + public async Task GetRoleByNameAsync_ShouldReturnRoleWithInputRoleName_WhenRoleExists() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }; + context.Roles.Add(role); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetRoleByNameAsync("Admin"); + + // Assert + Assert.NotNull(result); + Assert.Equal("Admin", result.RoleName); + } + + [Fact] + public async Task GetRoleByNameAsync_ShouldReturnNull_WhenRoleDoesNotExist() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }; + context.Roles.Add(role); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetRoleByNameAsync("DataManager"); + + // Assert + Assert.Null(result); + } + + [Fact] + public async Task AddRoleAsync_ShouldAddRoleToDatabase() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }; + + // Act + await _sut.AddRoleAsync(role); + + // Assert + Assert.Equal(1, context.Roles.Count()); + Assert.Contains(context.Roles, r => r is { Id: 1, RoleName: "Admin", RolePolicy: "gold" }); + } + + [Fact] + public async Task DeleteRole_ShouldRemoveRoleWithInputRoleNameAndReturnTrue_WhenRoleExists() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }; + context.Roles.Add(role); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.DeleteRoleAsync("Admin"); + + // Assert + Assert.True(result); + Assert.Equal(0, context.Roles.Count()); + } + + [Fact] + public async Task DeleteRole_ShouldReturnFalse_WhenRoleDoesNotExist() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }; + context.Roles.Add(role); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.DeleteRoleAsync("DataManager"); + + // Assert + Assert.False(result); + Assert.Equal(1, context.Roles.Count()); + } + + [Fact] + public async Task GetAllRolesPaginationAsync_ShouldReturnPaginatedResults_Whenever() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + context.Roles.AddRange( + new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }, + new Role { Id = 2, RoleName = "DataManager", RolePolicy = "silver" }, + new Role { Id = 3, RoleName = "DataAnalyst", RolePolicy = "bronze" } + ); + + await context.SaveChangesAsync(); + + var page = 0; + var limit = 2; + + // Act + var result = await _sut.GetAllRolesPaginationAsync(page, limit); + + // Assert + Assert.NotNull(result); + Assert.Equal(2, result.Count); + Assert.Equal("Admin", result[0].RoleName); + Assert.Equal("DataManager", result[1].RoleName); + } + + [Fact] + public async Task GetRolesCountAsync_ShouldReturnCountOfRoles_Whenever() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + context.Roles.AddRange( + new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }, + new Role { Id = 2, RoleName = "DataManager", RolePolicy = "silver" }, + new Role { Id = 3, RoleName = "DataAnalyst", RolePolicy = "bronze" } + ); + + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetRolesCountAsync(); + + // Assert + Assert.Equal(3, result); + } + + [Fact] + public async Task GetRolesByPolicyAsync_ShouldReturnRoles_WhenRolesExistForPolicy() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + context.Roles.AddRange( + new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }, + new Role { Id = 2, RoleName = "DataManager", RolePolicy = "silver" } + ); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetRolesByPolicyAsync("gold"); + + // Assert + Assert.NotNull(result); + Assert.Equal(1,result.Count()); + Assert.Contains("admin", result); + } + + [Fact] + public async Task GetRolesByPolicyAsync_ShouldReturnEmptyList_WhenNoRolesMatchPolicy() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + context.Roles.AddRange( + new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" } + ); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetRolesByPolicyAsync("silver"); + + // Assert + Assert.Empty(result); + } + +} \ No newline at end of file diff --git a/AnalysisData/TestProject/User/Repository/UserRepository/UserRepositoryTests.cs b/AnalysisData/TestProject/User/Repository/UserRepository/UserRepositoryTests.cs new file mode 100644 index 0000000..0ac6b3f --- /dev/null +++ b/AnalysisData/TestProject/User/Repository/UserRepository/UserRepositoryTests.cs @@ -0,0 +1,593 @@ +using AnalysisData.Data; +using AnalysisData.User.Model; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; + +namespace TestProject.User.Repository.UserRepository; + +public class UserRepositoryTests +{ + private readonly ServiceProvider _serviceProvider; + private readonly AnalysisData.User.Repository.UserRepository.UserRepository _sut; + + public UserRepositoryTests() + { + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .Options; + + var serviceCollection = new ServiceCollection(); + serviceCollection.AddScoped(_ => new ApplicationDbContext(options)); + _serviceProvider = serviceCollection.BuildServiceProvider(); + _sut = new AnalysisData.User.Repository.UserRepository.UserRepository(CreateDbContext()); + } + + private ApplicationDbContext CreateDbContext() + { + return _serviceProvider.GetRequiredService(); + } + + [Fact] + public async Task GetUserByUsernameAsync_ShouldReturnsUserWithInputUsername_WhenUserWithInputUsernameExists() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + //Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var user = new AnalysisData.User.Model.User + { + Username = "test", Password = "@Test1234", + Email = "test@gmail.com", + FirstName = "test", LastName = "test", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + context.Users.Add(user); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetUserByUsernameAsync("test"); + + // Assert + Assert.NotNull(result); + Assert.Equal("test", result.Username); + } + + [Fact] + public async Task GetUserByUsernameAsync_ShouldReturnsNull_WhenUserWithInputUsernameDoesNotExist() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + //Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var user = new AnalysisData.User.Model.User + { + Username = "test", Password = "@Test1234", + Email = "test@gmail.com", + FirstName = "test", LastName = "test", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + context.Users.Add(user); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetUserByUsernameAsync("nonExistentUser"); + + // Assert + Assert.Null(result); + } + + [Fact] + public async Task GetUserByEmailAsync_ShouldReturnsUserWithInputEmail_WhenUserWithInputEmailExists() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + //Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var user = new AnalysisData.User.Model.User + { + Username = "test", Password = "@Test1234", + Email = "test@gmail.com", + FirstName = "test", LastName = "test", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + context.Users.Add(user); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetUserByEmailAsync("test@gmail.com"); + + // Assert + Assert.NotNull(result); + Assert.Equal("test@gmail.com", result.Email); + } + + [Fact] + public async Task GetUserByEmailAsync_ShouldReturnsNull_WhenUserWithInputEmailDoesNotExist() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + //Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var user = new AnalysisData.User.Model.User + { + Username = "test", Password = "@Test1234", + Email = "test@gmail.com", + FirstName = "test", LastName = "test", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + context.Users.Add(user); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetUserByEmailAsync("nonExistentUser@gmail.com"); + + // Assert + Assert.Null(result); + } + + [Fact] + public async Task GetUserByIdAsync_ShouldReturnsUserWithInputId_WhenUserWithInputIdExists() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + //Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var userId = Guid.NewGuid(); + var user = new AnalysisData.User.Model.User + { + Id = userId, Username = "test", Password = "@Test1234", + Email = "test@gmail.com", FirstName = "test", LastName = "test", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + context.Users.Add(user); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetUserByIdAsync(userId); + + // Assert + Assert.NotNull(result); + Assert.Equal(userId, result.Id); + } + + [Fact] + public async Task GetUserByIdAsync_ShouldReturnsNull_WhenUserWithInputIdDoesNotExist() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + //Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var userId = Guid.NewGuid(); + var user = new AnalysisData.User.Model.User + { + Id = userId, Username = "test", Password = "@Test1234", + Email = "test@gmail.com", FirstName = "test", LastName = "test", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + context.Users.Add(user); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetUserByIdAsync(Guid.NewGuid()); + + // Assert + Assert.Null(result); + } + + [Fact] + public async Task GetAllUserPaginationAsync_ShouldReturnsPaginatedResults_WhenUsersExist() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var users = new List + { + new() + { + Username = "user1", Password = "@Test11234", + Email = "user1@gmail.com", FirstName = "user1", LastName = "user1", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }, + new() + { + Username = "user2", Password = "@Test21234", + Email = "user2@gmail.com", FirstName = "user2", LastName = "user2", + PhoneNumber = "09111111112", ImageURL = null, Role = role + }, + new() + { + Username = "user3", Password = "@Test31234", + Email = "user3@gmail.com", FirstName = "user3", LastName = "user3", + PhoneNumber = "09111111113", ImageURL = null, Role = role + }, + new() + { + Username = "user4", Password = "@Test41234", + Email = "user4@gmail.com", FirstName = "user4", LastName = "user4", + PhoneNumber = "09111111114", ImageURL = null, Role = role + }, + }; + + context.Roles.Add(role); + context.Users.AddRange(users); + await context.SaveChangesAsync(); + + var page = 1; + var limit = 2; + + // Act + var result = await _sut.GetAllUserPaginationAsync(page, limit); + + // Assert + Assert.NotNull(result); + Assert.Equal(2, result.Count); + Assert.Equal("user3", result[0].Username); + Assert.Equal("user4", result[1].Username); + } + + [Fact] + public async Task + GetAllUserPaginationAsync_ShouldReturnsAllUsers_WhenPageIsZeroAndLimitIsGreaterThanNumberOfExistingUsers() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var users = new List + { + new() + { + Username = "user1", Password = "@Test11234", + Email = "user1@gmail.com", FirstName = "user1", LastName = "user1", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }, + new() + { + Username = "user2", Password = "@Test21234", + Email = "user2@gmail.com", FirstName = "user2", LastName = "user2", + PhoneNumber = "09111111112", ImageURL = null, Role = role + }, + new() + { + Username = "user3", Password = "@Test31234", + Email = "user3@gmail.com", FirstName = "user3", LastName = "user3", + PhoneNumber = "09111111113", ImageURL = null, Role = role + }, + new() + { + Username = "user4", Password = "@Test41234", + Email = "user4@gmail.com", FirstName = "user4", LastName = "user4", + PhoneNumber = "09111111114", ImageURL = null, Role = role + }, + }; + + context.Roles.Add(role); + context.Users.AddRange(users); + await context.SaveChangesAsync(); + + var page = 0; + var limit = 10; + + // Act + var result = await _sut.GetAllUserPaginationAsync(page, limit); + + // Assert + Assert.NotNull(result); + Assert.Equal(4, result.Count); + } + + [Fact] + public async Task GetAllUserPaginationAsync_ShouldReturnsEmptyList_WhenPageIsOutOfRange() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var users = new List + { + new() + { + Username = "user1", Password = "@Test11234", + Email = "user1@gmail.com", FirstName = "user1", LastName = "user1", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }, + new() + { + Username = "user2", Password = "@Test21234", + Email = "user2@gmail.com", FirstName = "user2", LastName = "user2", + PhoneNumber = "09111111112", ImageURL = null, Role = role + }, + new() + { + Username = "user3", Password = "@Test31234", + Email = "user3@gmail.com", FirstName = "user3", LastName = "user3", + PhoneNumber = "09111111113", ImageURL = null, Role = role + }, + new() + { + Username = "user4", Password = "@Test41234", + Email = "user4@gmail.com", FirstName = "user4", LastName = "user4", + PhoneNumber = "09111111114", ImageURL = null, Role = role + }, + }; + + context.Roles.Add(role); + context.Users.AddRange(users); + await context.SaveChangesAsync(); + + var page = 3; + var limit = 2; + + // Act + var result = await _sut.GetAllUserPaginationAsync(page, limit); + + // Assert + Assert.Empty(result); + } + + [Fact] + public async Task GetUsersCountAsync_ShouldReturnsCountsOfUsers_Whenever() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var users = new List + { + new() + { + Username = "user1", Password = "@Test11234", + Email = "user1@gmail.com", FirstName = "user1", LastName = "user1", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }, + new() + { + Username = "user2", Password = "@Test21234", + Email = "user2@gmail.com", FirstName = "user2", LastName = "user2", + PhoneNumber = "09111111112", ImageURL = null, Role = role + }, + new() + { + Username = "user3", Password = "@Test31234", + Email = "user3@gmail.com", FirstName = "user3", LastName = "user3", + PhoneNumber = "09111111113", ImageURL = null, Role = role + }, + new() + { + Username = "user4", Password = "@Test41234", + Email = "user4@gmail.com", FirstName = "user4", LastName = "user4", + PhoneNumber = "09111111114", ImageURL = null, Role = role + }, + }; + + context.Roles.Add(role); + context.Users.AddRange(users); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetUsersCountAsync(); + + // Assert + Assert.Equal(4, result); + } + + + [Fact] + public async Task DeleteUserAsync_ShouldDeleteUserWithInputUserId_WhenUserWithInputUserIdIsExist() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var userId = Guid.NewGuid(); + var user = new AnalysisData.User.Model.User + { + Id = userId, Username = "user1", Password = "@Test11234", + Email = "user1@gmail.com", FirstName = "user1", LastName = "user1", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + + context.Roles.Add(role); + context.Users.Add(user); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.DeleteUserAsync(userId); + + // Assert + Assert.True(result); + Assert.Equal(0, context.Users.Count()); + } + + + [Fact] + public async Task DeleteUserAsync_ShouldReturnsNull_WhenUserWithInputUserIdIsDoesNotExist() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var userId = Guid.NewGuid(); + var user = new AnalysisData.User.Model.User + { + Id = userId, Username = "user1", Password = "@Test11234", + Email = "user1@gmail.com", FirstName = "user1", LastName = "user1", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + + context.Roles.Add(role); + context.Users.Add(user); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.DeleteUserAsync(Guid.NewGuid()); + + // Assert + Assert.False(result); + Assert.Equal(1, context.Users.Count()); + } + + [Fact] + public async Task AddUserAsync_ShouldAddsUserToDatabase() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var userId = Guid.NewGuid(); + var user = new AnalysisData.User.Model.User + { + Id = userId, Username = "user1", Password = "@Test11234", + Email = "user1@gmail.com", FirstName = "user1", LastName = "user1", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + context.Roles.Add(role); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.AddUserAsync(user); + + // Assert + Assert.True(result); + Assert.Equal(1, context.Users.Count()); + Assert.Contains(context.Users, u => u.Username == user.Username); + } + + [Fact] + public async Task UpdateUserAsync_ShouldReturnTrue_AndUpdateUser_WhenUserExists() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var role = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var userId = Guid.NewGuid(); + var user = new AnalysisData.User.Model.User + { + Id = userId, Username = "user1", Password = "@Test11234", + Email = "user1@gmail.com", FirstName = "user1", LastName = "user1", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + + context.Roles.Add(role); + context.Users.Add(user); + await context.SaveChangesAsync(); + + user.FirstName = "newUser"; + user.LastName = "newUser"; + + + // Act + var result = await _sut.UpdateUserAsync(userId, user); + + // Assert + Assert.True(result); + Assert.Contains(context.Users, u => u.Id == userId && u is { FirstName: "newUser", LastName: "newUser" }); + } + + [Fact] + public async Task + GetTopUsersByUsernameSearchAsync_ShouldReturnsMatchingUsersWhichContainsInputUsernameAndDoesNotBeDataAnalyst_WhenUsersDoNotBeDataAnalystAndContainsInputUsernameExist() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var roleAdmin = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var roleManager = new Role { RoleName = "Manager", RolePolicy = "silver" }; + var roleAnalyst = new Role { RoleName = "dataanalyst", RolePolicy = "bronze" }; + + var users = new List + { + new() + { + Username = "usertestname", Password = "@Test11234", + Email = "user1@gmail.com", FirstName = "user1", LastName = "user1", + PhoneNumber = "09111111111", ImageURL = null, Role = roleAdmin + }, + new() + { + Username = "testuser2", Password = "@Test21234", + Email = "user2@gmail.com", FirstName = "user2", LastName = "user2", + PhoneNumber = "09111111112", ImageURL = null, Role = roleManager + }, + new() + { + Username = "usertest3", Password = "@Test31234", + Email = "user3@gmail.com", FirstName = "user3", LastName = "user3", + PhoneNumber = "09111111113", ImageURL = null, Role = roleAnalyst + } + }; + + context.Roles.AddRange(roleAdmin, roleManager, roleAnalyst); + context.Users.AddRange(users); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetTopUsersByUsernameSearchAsync("test"); + + // Assert + Assert.NotNull(result); + var resultList = result.ToList(); + Assert.Equal(2, resultList.Count); + Assert.DoesNotContain(resultList, u => u.Username == "usertest3"); + } + + [Fact] + public async Task GetTopUsersByUsernameSearchAsync_ShouldReturnEmptyList_WhenNoUsersMatch() + { + using var scope = _serviceProvider.CreateScope(); + var context = CreateDbContext(); + + // Arrange + var roleAdmin = new Role { RoleName = "Admin", RolePolicy = "gold" }; + var roleManager = new Role { RoleName = "Manager", RolePolicy = "silver" }; + var roleAnalyst = new Role { RoleName = "dataanalyst", RolePolicy = "bronze" }; + + var users = new List + { + new() + { + Username = "usertestname", Password = "@Test11234", + Email = "user1@gmail.com", FirstName = "user1", LastName = "user1", + PhoneNumber = "09111111111", ImageURL = null, Role = roleAdmin + }, + new() + { + Username = "testuser2", Password = "@Test21234", + Email = "user2@gmail.com", FirstName = "user2", LastName = "user2", + PhoneNumber = "09111111112", ImageURL = null, Role = roleManager + }, + new() + { + Username = "usertest3", Password = "@Test31234", + Email = "user3@gmail.com", FirstName = "user3", LastName = "user3", + PhoneNumber = "09111111113", ImageURL = null, Role = roleAnalyst + } + }; + + context.Roles.AddRange(roleAdmin, roleManager, roleAnalyst); + context.Users.AddRange(users); + await context.SaveChangesAsync(); + + // Act + var result = await _sut.GetTopUsersByUsernameSearchAsync("NoUser"); + + // Assert + Assert.Empty(result); + } +} \ No newline at end of file diff --git a/AnalysisData/TestProject/User/Services/AdminService/AdminRegisterServiceTests.cs b/AnalysisData/TestProject/User/Services/AdminService/AdminRegisterServiceTests.cs new file mode 100644 index 0000000..e9fe226 --- /dev/null +++ b/AnalysisData/TestProject/User/Services/AdminService/AdminRegisterServiceTests.cs @@ -0,0 +1,157 @@ +using AnalysisData.Exception.UserException; +using AnalysisData.User.Model; +using AnalysisData.User.Repository.RoleRepository.Abstraction; +using AnalysisData.User.Repository.UserRepository.Abstraction; +using AnalysisData.User.Services.AdminService; +using AnalysisData.User.Services.SecurityPasswordService.Abstraction; +using AnalysisData.User.Services.ValidationService.Abstraction; +using AnalysisData.User.UserDto.UserDto; +using NSubstitute; +using NSubstitute.ExceptionExtensions; + +namespace TestProject.User.Services.AdminService; + +public class AdminRegisterServiceTests +{ + private readonly IUserRepository _userRepository; + private readonly IValidationService _validationService; + private readonly IRoleRepository _roleRepository; + private readonly IPasswordHasher _passwordHasher; + private readonly AdminRegisterService _sut; + + public AdminRegisterServiceTests() + { + _userRepository = Substitute.For(); + _validationService = Substitute.For(); + _roleRepository = Substitute.For(); + _passwordHasher = Substitute.For(); + + _sut = new AdminRegisterService( + _userRepository, + _validationService, + _roleRepository, + _passwordHasher); + } + + [Fact] + public async Task RegisterByAdminAsync_ShouldRegisterUser_WhenDataIsValid() + { + // Arrange + var userRegisterDto = new UserRegisterDto + { + Username = "newUser", + Email = "newuser@test.com", + Password = "Password123", + ConfirmPassword = "Password123", + FirstName = "New", + LastName = "User", + PhoneNumber = "1234567890", + RoleName = "Admin" + }; + + var existingRole = new Role { RoleName = "Admin" }; + _roleRepository.GetRoleByNameAsync(Arg.Is("admin")).Returns(existingRole); + + _userRepository.GetUserByEmailAsync(userRegisterDto.Email).Returns((AnalysisData.User.Model.User)null); + _userRepository.GetUserByUsernameAsync(userRegisterDto.Username).Returns((AnalysisData.User.Model.User)null); + + _passwordHasher.HashPassword(userRegisterDto.Password).Returns("hashedPassword"); + + // Act + await _sut.RegisterByAdminAsync(userRegisterDto); + + // Assert + await _userRepository.Received(1).AddUserAsync(Arg.Is(u => + u.Username == userRegisterDto.Username && + u.Email == userRegisterDto.Email && + u.FirstName == userRegisterDto.FirstName && + u.LastName == userRegisterDto.LastName && + u.PhoneNumber == userRegisterDto.PhoneNumber && + u.Password == "hashedPassword" && + u.Role.RoleName == userRegisterDto.RoleName + )); + + _validationService.Received(1).EmailCheck(userRegisterDto.Email); + _validationService.Received(1).PasswordCheck(userRegisterDto.Password); + _validationService.Received(1).PhoneNumberCheck(userRegisterDto.PhoneNumber); + } + + [Fact] + public async Task ValidateUserRegistrationDataAsync_ShouldThrowPasswordMismatchException_WhenPasswordsDoNotMatch() + { + // Arrange + var userRegisterDto = new UserRegisterDto + { + Username = "newUser", + Email = "newUser@example.com", + Password = "SecurePassword123", + ConfirmPassword = "DifferentPassword", + FirstName = "First", + LastName = "Last", + PhoneNumber = "1234567890", + RoleName = "admin" + }; + _roleRepository.GetRoleByNameAsync(userRegisterDto.RoleName).ThrowsAsync(new PasswordMismatchException()); + + // Act + var action = () => _sut.RegisterByAdminAsync(userRegisterDto); + + // Assert + await Assert.ThrowsAsync(action); + } + + [Fact] + public async Task ValidateUserInformation_ShouldThrowDuplicateUserException_WhenUserAlreadyExists() + { + // Arrange + var userRegisterDto = new UserRegisterDto + { + Username = "existingUsername", + Email = "existingEmail@gmail.com", + Password = "SecurePassword123", + ConfirmPassword = "SecurePassword123", + FirstName = "First", + LastName = "Last", + PhoneNumber = "09123456789", + RoleName = "admin" + }; + var role = new Role { RoleName = "admin", RolePolicy = "gold" }; + _roleRepository.GetRoleByNameAsync(userRegisterDto.RoleName.ToLower()).Returns(role); + var existingUserWithUsername = new AnalysisData.User.Model.User + { Id = Guid.NewGuid(), Username = "existingUsername", Email = "anotherEmail@gmail.com" }; + var existingUserWithEmail = new AnalysisData.User.Model.User + { Id = Guid.NewGuid(), Username = "anotherUsername", Email = "existingEmail@gmail.com" }; + + _userRepository.GetUserByUsernameAsync(userRegisterDto.Username).Returns(existingUserWithUsername); + _userRepository.GetUserByEmailAsync(userRegisterDto.Email).Returns(existingUserWithEmail); + // Act + var action = () => _sut.RegisterByAdminAsync(userRegisterDto); + // Assert + await Assert.ThrowsAsync(action); + } + + [Fact] + public async Task CheckExistenceRole_ShouldThrowRoleNotFoundException_WhenRoleDoesNotExist() + { + // Arrange + var userRegisterDto = new UserRegisterDto + { + Username = "newUser", + Email = "newUser@gmail.com", + Password = "SecurePassword123", + ConfirmPassword = "SecurePassword123", + FirstName = "First", + LastName = "Last", + PhoneNumber = "09123456789", + RoleName = "nonExistentRole" + }; + + _roleRepository.GetRoleByNameAsync(userRegisterDto.RoleName).ThrowsAsync(new RoleNotFoundException()); + + // Act + var action = () => _sut.RegisterByAdminAsync(userRegisterDto); + + // Assert + await Assert.ThrowsAsync(action); + } +} \ No newline at end of file diff --git a/AnalysisData/TestProject/User/Services/AdminService/AdminServiceTests.cs b/AnalysisData/TestProject/User/Services/AdminService/AdminServiceTests.cs new file mode 100644 index 0000000..bef9c75 --- /dev/null +++ b/AnalysisData/TestProject/User/Services/AdminService/AdminServiceTests.cs @@ -0,0 +1,224 @@ +using AnalysisData.Exception.UserException; +using AnalysisData.User.JwtService.abstractions; +using AnalysisData.User.Model; +using AnalysisData.User.Repository.RoleRepository.Abstraction; +using AnalysisData.User.Repository.UserRepository.Abstraction; +using AnalysisData.User.Services.ValidationService.Abstraction; +using AnalysisData.User.UserDto.UserDto; +using NSubstitute; + +namespace TestProject.User.Services.AdminService; + +public class AdminServiceTests +{ + private readonly IUserRepository _userRepository; + private readonly IValidationService _validationService; + private readonly IRoleRepository _roleRepository; + private readonly IJwtService _jwtService; + private readonly AnalysisData.User.Services.AdminService.AdminService _sut; + + public AdminServiceTests() + { + _userRepository = Substitute.For(); + _validationService = Substitute.For(); + _roleRepository = Substitute.For(); + _jwtService = Substitute.For(); + + _sut = new AnalysisData.User.Services.AdminService.AdminService( + _userRepository, + _validationService, + _roleRepository, + _jwtService); + } + + [Fact] + public async Task UpdateUserInformationByAdminAsync_ShouldUpdateUser_WhenInputDataIsValid() + { + // Arrange + var userId = Guid.NewGuid(); + var role = new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }; + var user = new AnalysisData.User.Model.User + { + Id = userId, + Username = "Username", + Password = "@Username123", + PhoneNumber = "09111111111", + FirstName = "Username", + LastName = "Username", + Email = "Email@gmail.com", + Role = role + }; + + var updateAdminDto = new UpdateAdminDto + { + Username = "newUsername", + Email = "newEmail@gmail.com", + FirstName = "NewFirstName", + LastName = "NewLastName", + PhoneNumber = "1234567890", + RoleName = "Admin" + }; + + _userRepository.GetUserByIdAsync(userId).Returns(user); + _userRepository.GetUserByUsernameAsync(updateAdminDto.Username).Returns((AnalysisData.User.Model.User)null); + _userRepository.GetUserByEmailAsync(updateAdminDto.Email).Returns((AnalysisData.User.Model.User)null); + _roleRepository.GetRoleByNameAsync(updateAdminDto.RoleName).Returns(role); + + + // Act + await _sut.UpdateUserInformationByAdminAsync(userId, updateAdminDto); + + // Assert + await _userRepository + .Received() + .UpdateUserAsync(userId, Arg.Is(u => + u.Username == updateAdminDto.Username && + u.Email == updateAdminDto.Email && + u.FirstName == updateAdminDto.FirstName && + u.LastName == updateAdminDto.LastName && + u.PhoneNumber == updateAdminDto.PhoneNumber && + u.Role.RoleName == updateAdminDto.RoleName + )); + + await _jwtService + .Received() + .UpdateUserCookie(updateAdminDto.Username, false); + } + + [Fact] + public async Task ValidateUserInformation_ShouldThrowDuplicateUserException_WhenUsernameOrEmailExists() + { + // Arrange + var userId = Guid.NewGuid(); + var role = new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }; + var user = new AnalysisData.User.Model.User + { + Username = "test", Password = "@Test1234", + Email = "test@gmail.com", + FirstName = "test", LastName = "test", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + + var updateAdminDto = new UpdateAdminDto + { + Username = "existingUsername", + Email = "existingEmail@test.com" + }; + + var existingUserWithUsername = new AnalysisData.User.Model.User + { Id = Guid.NewGuid(), Username = "existingUsername", Email = "anotherEmail@gmail.com" }; + var existingUserWithEmail = new AnalysisData.User.Model.User + { Id = Guid.NewGuid(), Username = "anotherUsername", Email = "existingEmail@gmail.com" }; + + _userRepository.GetUserByIdAsync(userId).Returns(user); + _userRepository.GetUserByUsernameAsync(updateAdminDto.Username).Returns(existingUserWithUsername); + _userRepository.GetUserByEmailAsync(updateAdminDto.Email).Returns(existingUserWithEmail); + + // Act + var action = () => _sut.UpdateUserInformationByAdminAsync(userId, updateAdminDto); + + // Assert + await Assert.ThrowsAsync(action); + } + + [Fact] + public async Task CheckExistenceOfRole_ShouldThrowRoleNotFoundException_WhenRoleDoesNotExist() + { + // Arrange + var userId = Guid.NewGuid(); + var role = new Role { Id = 1, RoleName = "Admin", RolePolicy = "gold" }; + var user = new AnalysisData.User.Model.User + { + Username = "test", Password = "@Test1234", + Email = "test@gmail.com", + FirstName = "test", LastName = "test", + PhoneNumber = "09111111111", ImageURL = null, Role = role + }; + + var updateAdminDto = new UpdateAdminDto + { + RoleName = "NonExistentRole" + }; + + _userRepository.GetUserByIdAsync(userId).Returns(user); + _roleRepository.GetRoleByNameAsync(updateAdminDto.RoleName).Returns((Role)null); + + // Act + var action = () => _sut.UpdateUserInformationByAdminAsync(userId, updateAdminDto); + + // Assert + await Assert.ThrowsAsync(action); + } + + [Fact] + public async Task DeleteUserAsync_ShouldReturnTrue_WhenUserExists() + { + // Arrange + var userId = Guid.NewGuid(); + _userRepository.DeleteUserAsync(userId).Returns(true); + + // Act + var result = await _sut.DeleteUserAsync(userId); + + // Assert + Assert.True(result); + } + + [Fact] + public async Task DeleteUserAsync_ShouldThrowUserNotFoundException_WhenUserDoesNotExist() + { + // Arrange + var userId = Guid.NewGuid(); + _userRepository.DeleteUserAsync(userId).Returns(false); + + // Act + var action = () => _sut.DeleteUserAsync(userId); + + // Assert + await Assert.ThrowsAsync(action); + } + + [Fact] + public async Task GetUserCountAsync_ShouldReturnUserCount_WhenCalled() + { + // Arrange + var expectedCount = 5; + _userRepository.GetUsersCountAsync().Returns(expectedCount); + + // Act + var result = await _sut.GetUserCountAsync(); + + // Assert + Assert.Equal(expectedCount, result); + } + + [Fact] + public async Task GetAllUserAsync_ShouldReturnPaginatedUsers_WhenUsersExist() + { + // Arrange + var users = new List + { + new() + { + Id = Guid.NewGuid(), Username = "user1", FirstName = "First1", LastName = "Last1", + Email = "email1@gmail.com", PhoneNumber = "09111111111", Role = new Role { RoleName = "Admin" } + }, + new() + { + Id = Guid.NewGuid(), Username = "user2", FirstName = "First2", LastName = "Last2", + Email = "email2@gmail.com", PhoneNumber = "09222222222", Role = new Role { RoleName = "DataManager" } + }, + }; + + _userRepository.GetAllUserPaginationAsync(0, 2).Returns(users); + + // Act + var result = await _sut.GetAllUserAsync(0, 2); + + // Assert + Assert.NotNull(result); + Assert.Equal(2, result.Count); + Assert.Equal("user1", result[0].Username); + Assert.Equal("user2", result[1].Username); + } +} \ No newline at end of file