From ded21d7f7b7ed5698a4d397d3cbbf3af658f8864 Mon Sep 17 00:00:00 2001 From: msaad Date: Fri, 20 Sep 2024 11:37:56 +0100 Subject: [PATCH] Modify Database --- .../WorkItem/WorkItemExternalService.cs | 2 +- .../ProfileUser/ProfileUserCommandHandler.cs | 1 - .../TimeLogService.Database.sqlproj | 2 ++ .../dbo/Tables/Organization.sql | 10 ++-------- .../TimeLogService.DataBase/dbo/Tables/User.sql | 7 +------ .../TimeLogService.DataBase/dbo/Tables/UserPath.sql | 12 ++++++++++++ .../dbo/Tables/UserPathOrganizations.sql | 8 ++++++++ 7 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 src/TimeLogService/TimeLogService.DataBase/dbo/Tables/UserPath.sql create mode 100644 src/TimeLogService/TimeLogService.DataBase/dbo/Tables/UserPathOrganizations.sql diff --git a/src/AzureDevopsService/AzureDevopsService.Application/AzureDevopsExternalResourceService/WorkItem/WorkItemExternalService.cs b/src/AzureDevopsService/AzureDevopsService.Application/AzureDevopsExternalResourceService/WorkItem/WorkItemExternalService.cs index c79a9fd..b70d7bc 100644 --- a/src/AzureDevopsService/AzureDevopsService.Application/AzureDevopsExternalResourceService/WorkItem/WorkItemExternalService.cs +++ b/src/AzureDevopsService/AzureDevopsService.Application/AzureDevopsExternalResourceService/WorkItem/WorkItemExternalService.cs @@ -37,7 +37,7 @@ public async Task> GetWorkItemByUse return new WiqlBadRequestResponce() { Email = resource.Email, - ErrorCode = (int?)workItemResponse.StatusCode, + ErrorCode = (int)workItemResponse.StatusCode, Message = AzureResponseMessage.WorkItemError, Path = resource.Path, }; diff --git a/src/AzureDevopsService/AzureDevopsService.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommandHandler.cs b/src/AzureDevopsService/AzureDevopsService.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommandHandler.cs index 828dc02..3a8a039 100644 --- a/src/AzureDevopsService/AzureDevopsService.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommandHandler.cs +++ b/src/AzureDevopsService/AzureDevopsService.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommandHandler.cs @@ -14,7 +14,6 @@ public async Task Handle(ProfileUserCommand request, CancellationToken cancellat OneOf adminInfoResponse = await _userProfileApiClient.GetAdminInfo(request.BaseRequest); if (adminInfoResponse.IsT0) { - OneOf organizationResponce = await _userProfileApiClient.GeUserOrganizations( new GetUserOrganizationRequest { diff --git a/src/TimeLogService/TimeLogService.DataBase/TimeLogService.Database.sqlproj b/src/TimeLogService/TimeLogService.DataBase/TimeLogService.Database.sqlproj index 3551264..a8758d9 100644 --- a/src/TimeLogService/TimeLogService.DataBase/TimeLogService.Database.sqlproj +++ b/src/TimeLogService/TimeLogService.DataBase/TimeLogService.Database.sqlproj @@ -68,6 +68,8 @@ + + diff --git a/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/Organization.sql b/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/Organization.sql index e1fe033..dc9a877 100644 --- a/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/Organization.sql +++ b/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/Organization.sql @@ -1,17 +1,11 @@ CREATE TABLE [dbo].[Organization] ( [Id] INT IDENTITY (1, 1) PRIMARY KEY NOT NULL, - [UserId] NVARCHAR(100) not null, [Name] Varchar(255) not null, [AccountId] NVARCHAR(100) NOT NULL unique, [AccountUri] VARCHAR(200) NOT NULL, - [IsAionTimeApproved] BIT NOT NULL - - CONSTRAINT FKUserOrganization - FOREIGN KEY (UserId) - REFERENCES [dbo].[User] (UserId) - ON DELETE CASCADE - ON UPDATE CASCADE, + [IsAionTimeApproved] BIT NOT NULL, + [CreationDate] datetime not null ) GO diff --git a/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/User.sql b/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/User.sql index e30e1d4..73dd12e 100644 --- a/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/User.sql +++ b/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/User.sql @@ -1,10 +1,5 @@ CREATE TABLE [dbo].[User] ( [Id] INT IDENTITY (1, 1) PRIMARY KEY NOT NULL, - [UserId] NVARCHAR(100) NOT NULL UNIQUE, - [EmailAddress] VARCHAR(50) NOT NULL, - [PublicAlias] NVARCHAR(100) NOT NULL, - [CoreRevision] INT NOT NULL, - [TimeStamp] DATETIME NOT NULL, - [Revision] INT NOT NULL + [EmailAddress] VARCHAR(50) NOT NULL UNIQUE, ) diff --git a/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/UserPath.sql b/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/UserPath.sql new file mode 100644 index 0000000..be1db8f --- /dev/null +++ b/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/UserPath.sql @@ -0,0 +1,12 @@ +CREATE TABLE [dbo].[UserPath] +( + [Id] INT NOT NULL PRIMARY KEY, + [UserId] INT NOT NULL, + [PathType] NVARCHAR(150) NOT NULL, + + CONSTRAINT FK_UserPath_Uesr + FOREIGN KEY (UserId) + REFERENCES [dbo].[User] (Id) + ON DELETE CASCADE + ON UPDATE CASCADE +) diff --git a/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/UserPathOrganizations.sql b/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/UserPathOrganizations.sql new file mode 100644 index 0000000..b4832b7 --- /dev/null +++ b/src/TimeLogService/TimeLogService.DataBase/dbo/Tables/UserPathOrganizations.sql @@ -0,0 +1,8 @@ +CREATE TABLE [dbo].[UserPathOrganizations] ( + [PathId] INT NOT NULL, + [OrganizationId] INT NOT NULL, + [CreationDate] DATETIME + PRIMARY KEY ([PathId], [OrganizationId]) NOT NULL, + FOREIGN KEY ([PathId]) REFERENCES [dbo].[UserPath]([Id]), + FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization]([Id]) +); \ No newline at end of file