Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
Completed project creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Utar94 committed Apr 26, 2024
1 parent 8c4d875 commit e779f3e
Show file tree
Hide file tree
Showing 46 changed files with 1,428 additions and 12 deletions.
12 changes: 12 additions & 0 deletions backend/Master.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Master.Contracts",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Master.Infrastructure", "src\Logitar.Master.Infrastructure\Logitar.Master.Infrastructure.csproj", "{4609D92F-C8C6-4F21-B76D-9A40CCF07BD5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Master.EntityFrameworkCore", "src\Logitar.Master.EntityFrameworkCore\Logitar.Master.EntityFrameworkCore.csproj", "{24E6FB66-4EB6-4612-B61E-43CD55D6203A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Master.EntityFrameworkCore.SqlServer", "src\Logitar.Master.EntityFrameworkCore.SqlServer\Logitar.Master.EntityFrameworkCore.SqlServer.csproj", "{448F5F9C-2F5A-48D5-AA28-5AC5A2731823}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -48,6 +52,14 @@ Global
{4609D92F-C8C6-4F21-B76D-9A40CCF07BD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4609D92F-C8C6-4F21-B76D-9A40CCF07BD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4609D92F-C8C6-4F21-B76D-9A40CCF07BD5}.Release|Any CPU.Build.0 = Release|Any CPU
{24E6FB66-4EB6-4612-B61E-43CD55D6203A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24E6FB66-4EB6-4612-B61E-43CD55D6203A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24E6FB66-4EB6-4612-B61E-43CD55D6203A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24E6FB66-4EB6-4612-B61E-43CD55D6203A}.Release|Any CPU.Build.0 = Release|Any CPU
{448F5F9C-2F5A-48D5-AA28-5AC5A2731823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{448F5F9C-2F5A-48D5-AA28-5AC5A2731823}.Debug|Any CPU.Build.0 = Debug|Any CPU
{448F5F9C-2F5A-48D5-AA28-5AC5A2731823}.Release|Any CPU.ActiveCfg = Release|Any CPU
{448F5F9C-2F5A-48D5-AA28-5AC5A2731823}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
11 changes: 11 additions & 0 deletions backend/src/Logitar.Master.Application/Caching/ICacheService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Logitar.EventSourcing;
using Logitar.Master.Contracts.Actors;

namespace Logitar.Master.Application.Caching;

public interface ICacheService
{
Actor? GetActor(ActorId id);
void RemoveActor(ActorId id);
void SetActor(Actor actor);
}
5 changes: 1 addition & 4 deletions backend/src/Logitar.Master.Domain/Projects/ProjectId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ public ProjectId(AggregateId aggregateId)

private ProjectId(string value)
{
value = value.Trim();
// TODO(fpion): validate value

AggregateId = new(value);
AggregateId = new(value.Trim());
}

public static ProjectId NewId() => new(AggregateId.NewId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using FluentValidation;
using Logitar.Master.Domain.Shared;

namespace Logitar.Master.Domain.Projects;

public class UniqueKeyValidator : AbstractValidator<string>
{
private const string AllowedCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

public UniqueKeyValidator()
{
RuleFor(x => x).NotEmpty().MaximumLength(UniqueKeyUnit.MaximumLength); // TODO(fpion): AllowedCharacters
RuleFor(x => x).NotEmpty().MaximumLength(UniqueKeyUnit.MaximumLength).SetValidator(new AllowedCharactersValidator(AllowedCharacters));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using FluentValidation;

namespace Logitar.Master.Domain.Shared;

public class AllowedCharactersValidator : AbstractValidator<string>
{
public AllowedCharactersValidator(string? allowedCharacters)
{
if (allowedCharacters != null)
{
RuleFor(x => x).Must(x => x.All(allowedCharacters.Contains)).WithErrorCode(nameof(AllowedCharactersValidator))
.WithMessage($"'{{PropertyName}}' may only contain the following characters: '{allowedCharacters}'.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Logitar.EventSourcing.EntityFrameworkCore.SqlServer;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Logitar.Master.EntityFrameworkCore.SqlServer;

public static class DependencyInjectionExtensions
{
private const string ConfigurationKey = "SQLCONNSTR_Master";

public static IServiceCollection AddLogitarMasterWithEntityFrameworkCoreSqlServer(this IServiceCollection services, IConfiguration configuration)
{
string? connectionString = Environment.GetEnvironmentVariable(ConfigurationKey);
if (string.IsNullOrWhiteSpace(connectionString))
{
connectionString = configuration.GetValue<string>(ConfigurationKey);
}
if (string.IsNullOrWhiteSpace(connectionString))
{
throw new ArgumentException($"The configuration '{ConfigurationKey}' could not be found.", nameof(configuration));
}
return services.AddLogitarMasterWithEntityFrameworkCoreSqlServer(connectionString.Trim());
}
public static IServiceCollection AddLogitarMasterWithEntityFrameworkCoreSqlServer(this IServiceCollection services, string connectionString)
{
return services
.AddDbContext<MasterContext>(options => options.UseSqlServer(connectionString, b => b.MigrationsAssembly("Logitar.Master.EntityFrameworkCore.SqlServer")))
.AddLogitarEventSourcingWithEntityFrameworkCoreSqlServer(connectionString)
.AddLogitarMasterWithEntityFrameworkCore()
.AddSingleton<ISqlHelper, SqlServerHelper>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Logitar.Data.SqlServer" Version="3.0.0" />
<PackageReference Include="Logitar.EventSourcing.EntityFrameworkCore.SqlServer" Version="5.0.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Logitar.Master.EntityFrameworkCore\Logitar.Master.EntityFrameworkCore.csproj" />
</ItemGroup>

</Project>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e779f3e

Please sign in to comment.