Skip to content

Commit

Permalink
Merge pull request #60 from TunNetCom/FixAndUpgrade
Browse files Browse the repository at this point in the history
Upgrade azure contracts , add table to time log
  • Loading branch information
MarwenSaad authored Sep 15, 2024
2 parents 4fdf718 + e31331c commit 9cfa710
Show file tree
Hide file tree
Showing 42 changed files with 930 additions and 184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public async Task Handle(ProfileUserCommand request, CancellationToken cancellat
Path = adminInfoResponse!.AsT0!.Path,
});

await endpoint.Send(organizationResponce.AsT0, cancellationToken);
adminInfoResponse.AsT0.UserAccount = organizationResponce.AsT0;
await endpoint.Send(adminInfoResponse.AsT0, cancellationToken);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ public class UserProfile : BaseRequest

[JsonProperty("revision")]
public int Revision { get; set; }

[JsonProperty("UserAccount")]
public UserAccount? UserAccount { get; set; }
}
2 changes: 1 addition & 1 deletion src/TimeLogService/TimeLogService.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{
using (IServiceScope scope = app.Services.CreateScope())
{
TunNetComAionTimeTimeLogServiceDataBaseContext dbContext = scope.ServiceProvider.GetRequiredService<TunNetComAionTimeTimeLogServiceDataBaseContext>();
TimeLogServiceDataBaseContext dbContext = scope.ServiceProvider.GetRequiredService<TimeLogServiceDataBaseContext>();
_ = dbContext.Database.EnsureCreated();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using TimeLogService.Application.AutoMapping;
using TimeLogService.Contracts.DTOs.Request;
using TimeLogService.Domain.Models.Dbo;
using Project = TimeLogService.Domain.Models.Dbo.Project;
using WorkItem = TimeLogService.Domain.Models.Dbo.WorkItem;
using Project = TimeLogService.Domain.Models.Project;
using WorkItem = TimeLogService.Domain.Models.WorkItem;
using WorkItemRequest = TimeLogService.Contracts.DTOs.Request.WorkItemRequest;

namespace TimeLogService.Application.AutoMapping
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace TimeLogService.Application.Feature.UserAction.Commands.AddUser;

public record class AddUserCommand(UserProfile UserProfile) : IRequest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using TimeLogService.Domain.Interfaces.Repositories;

namespace TimeLogService.Application.Feature.UserAction.Commands.AddUser
{
public class AddUserCommandHandler(IRepository<User> repository) : IRequestHandler<AddUserCommand>
{
private readonly IRepository<User> _repository = repository;

public async Task Handle(AddUserCommand request, CancellationToken cancellationToken)
{
await _repository.AddAsync(request.UserProfile);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
global using WebhookService.Contracts.EventModels.SharedModels.ResourcesModels;
global using static MassTransit.Logging.OperationName;
global using static Org.BouncyCastle.Math.EC.ECCurve;
global using RabbitMqSettings = TimeLogService.Contracts.Settings.RabbitMqSettings;
global using RabbitMqSettings = TimeLogService.Contracts.Settings.RabbitMqSettings;
global using TimeLogService.Domain.Models;
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@
<ProjectReference Include="..\TimeLogService.Infrastructure\TimeLogService.Infrastructure.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Feature\UserAction\Commands\DeleteUser\" />
<Folder Include="Feature\UserAction\Commands\UpdateUser\" />
<Folder Include="Feature\UserAction\Queries\GetUserById\" />
<Folder Include="Feature\UserAction\Queries\GetUsers\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Operations Version="1.0" xmlns="http://schemas.microsoft.com/sqlserver/dac/Serialization/2012/02">
<Operation Name="Rename Refactor" Key="9ccea88e-7173-493c-bd00-e62b93839a91" ChangeDateTime="09/15/2024 17:13:43">
<Property Name="ElementName" Value="[dbo].[Project].[visibility]" />
<Property Name="ElementType" Value="SqlSimpleColumn" />
<Property Name="ParentElementName" Value="[dbo].[Project]" />
<Property Name="ParentElementType" Value="SqlTable" />
<Property Name="NewName" Value="Visibility" />
</Operation>
</Operations>
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@
<Build Include="dbo\Tables\WorkItem.sql" />
<Build Include="dbo\Tables\WorkItemHistory.sql" />
<Build Include="dbo\Tables\WorkItemTimeLog.sql" />
<Build Include="dbo\Tables\User.sql" />
<Build Include="dbo\Tables\AionTimeSubscription.sql" />
<Build Include="dbo\Tables\AionTimeSubscriptionHistory.sql" />
</ItemGroup>
<ItemGroup>
<None Include="TunNetCom.AionTime.TimeLogService.DataBase.publish.xml" />
<None Include="TimeLogService.Database.publish.xml" />
</ItemGroup>
<ItemGroup>
<RefactorLog Include="TimeLogService.Database.refactorlog" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE [dbo].[AionTimeSubscription]
(
[Id] INT IDENTITY (1, 1) PRIMARY KEY NOT NULL,
[SubsecriptionDate] DATETIME NULL,
[ExpirationDate] DATETIME NULL,
[OrganizationId] INT NOT NULL,

CONSTRAINT FKOrganizationSubscription
FOREIGN KEY (OrganizationId)
REFERENCES [dbo].[Organization] (Id)
ON DELETE CASCADE
ON UPDATE CASCADE,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE [dbo].[AionTimeSubscriptionHistory]
(
[Id] INT NOT NULL PRIMARY KEY,
[SubscriptionId] int NOT NULL,
[SubscriptionDate] DATE NOT NULL,

CONSTRAINT FKSubscriptionSubscriptionHistory
FOREIGN KEY (SubscriptionId)
REFERENCES [dbo].[AionTimeSubscription] (Id)
ON DELETE CASCADE
ON UPDATE CASCADE,

)
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
CREATE TABLE [dbo].[Organization]
(
[Id] INT IDENTITY (1, 1) PRIMARY KEY NOT NULL,
[Name] Varchar(255) 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,
)

GO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
(
[Id] INT IDENTITY (1, 1) PRIMARY KEY NOT NULL,
[OrganizationId] INT NOT NULL,
[ProjectId] NVARCHAR(100) NOT NULL UNIQUE,
[Name] VARCHAR(50) NOT NULL,
[State] INT NULL,
[Visibility] VARCHAR(50) NULL,
[LastUpdateTime] DATETIME NULL,
[Url] VARCHAR(200) NOT NULL,
CONSTRAINT FKOrganisationProject
FOREIGN KEY (OrganizationId)
REFERENCES [dbo].[Organization] (Id)
ON DELETE CASCADE
ON UPDATE CASCADE
ON UPDATE CASCADE
);
10 changes: 10 additions & 0 deletions src/TimeLogService/TimeLogService.DataBase/dbo/Tables/User.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace TimeLogService.Domain.Models;

public partial class AionTimeSubscription : BaseEntity
{
public DateTime? SubsecriptionDate { get; set; }

public DateTime? ExpirationDate { get; set; }

public int OrganizationId { get; set; }

public virtual IReadOnlyCollection<AionTimeSubscriptionHistory>? AionTimeSubscriptionHistories { get; set; } // = new List<AionTimeSubscriptionHistory>();

public virtual Organization? Organization { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace TimeLogService.Domain.Models;

public partial class AionTimeSubscriptionHistory : BaseEntity
{
public int SubscriptionId { get; set; }

public DateTime SubscriptionDate { get; set; }

public virtual AionTimeSubscription? Subscription { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
namespace TimeLogService.Domain.Models.Dbo;
namespace TimeLogService.Domain.Models;

public partial class Organization : BaseEntity
{
private readonly List<Project> _projects;
public string UserId { get; set; } = null!;

protected Organization(string name)
{
Name = name;
_projects = [];
}
public string Name { get; set; } = null!;

public IReadOnlyCollection<Project> Projects => _projects.AsReadOnly();
public string AccountId { get; set; } = null!;

public string Name { get; private set; }
public Uri AccountUri { get; set; } = null!;

public bool IsAionTimeApproved { get; set; }

public virtual IReadOnlyCollection<AionTimeSubscription>? AionTimeSubscriptions { get; set; }

public virtual IReadOnlyCollection<Project>? Projects { get; set; }

public virtual User? User { get; set; }
}
18 changes: 13 additions & 5 deletions src/TimeLogService/TimeLogService.Domain/Models/dbo/Project.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
namespace TimeLogService.Domain.Models.Dbo;
namespace TimeLogService.Domain.Models;

public partial class Project : BaseEntity
{
public int OrganizationId { get; set; }

public virtual Organization? Organization { get; set; }
public string ProjectId { get; set; } = null!;

#pragma warning disable CA2227 // Collection properties should be read only
public virtual ICollection<WorkItem>? WorkItems { get; set; }
#pragma warning restore CA2227 // Collection properties should be read only
public string Name { get; set; } = null!;

public string? State { get; set; }

public int? Revision { get; set; }

public string? Visibility { get; set; }

public DateTime? LastUpdateTime { get; set; }

public string Url { get; set; } = null!;
}
18 changes: 18 additions & 0 deletions src/TimeLogService/TimeLogService.Domain/Models/dbo/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace TimeLogService.Domain.Models;

public partial class User : BaseEntity
{
public string UserId { get; set; } = null!;

public string EmailAddress { get; set; } = null!;

public string PublicAlias { get; set; } = null!;

public int CoreRevision { get; set; }

public DateTime TimeStamp { get; set; }

public int Revision { get; set; }

public virtual IReadOnlyCollection<Organization>? Organizations { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace TimeLogService.Domain.Models.Dbo;
namespace TimeLogService.Domain.Models;

public partial class WorkItem : BaseEntity
{
Expand All @@ -8,10 +8,7 @@ public partial class WorkItem : BaseEntity

public virtual Project? Project { get; set; }

#pragma warning disable CA2227 // Collection properties should be read only
public virtual ICollection<WorkItemHistory>? WorkItemHistories { get; set; }

public virtual ICollection<WorkItemTimeLog>? WorkItemTimeLogs { get; set; }
#pragma warning restore CA2227 // Collection properties should be read only
public virtual IReadOnlyCollection<WorkItemHistory>? WorkItemHistories { get; set; }

public virtual IReadOnlyCollection<WorkItemTimeLog>? WorkItemTimeLogs { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace TimeLogService.Domain.Models.Dbo;
namespace TimeLogService.Domain.Models;

public partial class WorkItemHistory : BaseEntity
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace TimeLogService.Domain.Models.Dbo;
namespace TimeLogService.Domain.Models;

public partial class WorkItemTimeLog : BaseEntity
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EfCore.SchemaCompare" Version="8.0.0" />
<PackageReference Include="EfCore.SchemaCompare" Version="8.0.4" />
<PackageReference Include="MediatR" Version="12.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
28 changes: 6 additions & 22 deletions src/TimeLogService/TimeLogService.Domain/efpt.config.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,29 @@
{
"CodeGenerationMode": 4,
"ContextClassName": "TunNetCom.AionTime.TimeLogService.DatabaseContext",
"ContextClassName": "TimeLogService.DatabaseContext",
"ContextNamespace": null,
"DefaultDacpacSchema": null,
"FilterSchemas": false,
"IncludeConnectionString": false,
"ModelNamespace": null,
"OutputContextPath": null,
"OutputPath": "Models",
"PreserveCasingWithRegex": true,
"ProjectRootNamespace": "TunNetCom.AionTime.TimeLogService.Domain",
"ProjectRootNamespace": "TimeLogService.Domain",
"Schemas": null,
"SelectedHandlebarsLanguage": 2,
"SelectedToBeGenerated": 2,
"SelectedToBeGenerated": 0,
"T4TemplatePath": null,
"Tables": [
{
"Name": "[dbo].[Organization]",
"ObjectType": 0
},
{
"Name": "[dbo].[Project]",
"ObjectType": 0
},
{
"Name": "[dbo].[WorkItem]",
"ObjectType": 0
},
{
"Name": "[dbo].[WorkItemHistory]",
"ObjectType": 0
},
{
"Name": "[dbo].[WorkItemTimeLog]",
"ObjectType": 0
}
],
"UiHint": "..\\TunNetCom.AionTime.TimeLogService.DataBase\\TunNetCom.AionTime.TimeLogService.Database.sqlproj",
"UiHint": null,
"UncountableWords": null,
"UseAsyncStoredProcedureCalls": true,
"UseBoolPropertiesWithoutDefaultSql": false,
"UseDatabaseNames": false,
"UseDatabaseNames": true,
"UseDateOnlyTimeOnly": false,
"UseDbContextSplitting": true,
"UseDecimalDataAnnotationForSprocResult": true,
Expand Down
Loading

0 comments on commit 9cfa710

Please sign in to comment.