Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 61172c6139 |
+1
-5
@@ -19,10 +19,6 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- dotnet pack LiteCharms.Features/LiteCharms.Features.csproj -c Release -p:PackageVersion=$VERSION -o dist/
|
- dotnet pack LiteCharms.Features/LiteCharms.Features.csproj -c Release -p:PackageVersion=$VERSION -o dist/
|
||||||
- dotnet nuget push dist/LiteCharms.Features.$VERSION.nupkg --api-key $NEXUS_KEY --source $NEXUS_URL
|
- dotnet nuget push dist/LiteCharms.Features.$VERSION.nupkg --api-key $NEXUS_KEY --source $NEXUS_URL
|
||||||
- dotnet pack LiteCharms.Features.TechShop/LiteCharms.Features.TechShop.csproj -c Release -p:PackageVersion=$VERSION -o dist/
|
|
||||||
- dotnet nuget push dist/LiteCharms.Features.TechShop.$VERSION.nupkg --api-key $NEXUS_KEY --source $NEXUS_URL
|
|
||||||
- dotnet pack LiteCharms.Features.MidrandBooks/LiteCharms.Features.MidrandBooks.csproj -c Release -p:PackageVersion=$VERSION -o dist/
|
|
||||||
- dotnet nuget push dist/LiteCharms.Features.MidrandBooks.$VERSION.nupkg --api-key $NEXUS_KEY --source $NEXUS_URL
|
|
||||||
|
|
||||||
- name: gitea-tag-release
|
- name: gitea-tag-release
|
||||||
image: alpine/git
|
image: alpine/git
|
||||||
@@ -45,7 +41,7 @@ steps:
|
|||||||
\"tag_name\": \"$VERSION\",
|
\"tag_name\": \"$VERSION\",
|
||||||
\"target_commitish\": \"${DRONE_COMMIT_SHA}\",
|
\"target_commitish\": \"${DRONE_COMMIT_SHA}\",
|
||||||
\"name\": \"Library Suite $VERSION\",
|
\"name\": \"Library Suite $VERSION\",
|
||||||
\"body\": \"### Published NuGet Packages\nAll packages versioned as **$VERSION**:\n* LiteCharms.Features\n* LiteCharms.Features.TechShop\n* LiteCharms.Features.MidrandBooks\n\n[View in Nexus](https://nexus.khongisa.co.za/repository/nuget-group/)\",
|
\"body\": \"### Published NuGet Packages\nAll packages versioned as **$VERSION**:\n* LiteCharms.Features\n\n[View in Nexus](https://nexus.khongisa.co.za/repository/nuget-group/)\",
|
||||||
\"draft\": false,
|
\"draft\": false,
|
||||||
\"prerelease\": false
|
\"prerelease\": false
|
||||||
}"
|
}"
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
|
||||||
using LiteCharms.Features.MidrandBooks.Extensions;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.MidrandBooks.Tests;
|
|
||||||
|
|
||||||
public class Fixture : IDisposable
|
|
||||||
{
|
|
||||||
public IConfiguration Configuration { get; set; }
|
|
||||||
|
|
||||||
public IServiceProvider Services { get; set; }
|
|
||||||
|
|
||||||
public IMediator Mediator { get; set; }
|
|
||||||
|
|
||||||
public Fixture()
|
|
||||||
{
|
|
||||||
Configuration = new ConfigurationBuilder()
|
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
|
||||||
.AddUserSecrets<Fixture>()
|
|
||||||
.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: true)
|
|
||||||
.AddEnvironmentVariables()
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
Services = new ServiceCollection()
|
|
||||||
.AddMediator()
|
|
||||||
.AddLogging()
|
|
||||||
//.AddMidrandShopServices()
|
|
||||||
.AddEmailServiceBus()
|
|
||||||
.AddGarageS3(Configuration)
|
|
||||||
.AddMidrandShopDatabase(Configuration)
|
|
||||||
.AddEmailServices(Configuration)
|
|
||||||
.AddSingleton(Configuration)
|
|
||||||
.BuildServiceProvider();
|
|
||||||
|
|
||||||
Mediator = Services.GetRequiredService<IMediator>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() { }
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<IsPackable>false</IsPackable>
|
|
||||||
<UserSecretsId>b205af96-ceef-44e1-851c-458c9fd1c437</UserSecretsId>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="coverlet.collector" Version="10.0.1">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Mediator.SourceGenerator" Version="3.0.2">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
|
|
||||||
<PackageReference Include="xunit" Version="2.9.3" />
|
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<ItemGroup>
|
|
||||||
<Using Include="Mediator" />
|
|
||||||
<Using Include="Xunit.Abstractions" />
|
|
||||||
<Using Include="Microsoft.Extensions.DependencyInjection" />
|
|
||||||
<Using Include="Microsoft.Extensions.Configuration" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\LiteCharms.Features.MidrandBooks\LiteCharms.Features.MidrandBooks.csproj" />
|
|
||||||
<ProjectReference Include="..\LiteCharms.Features\LiteCharms.Features.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Using Include="Xunit" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"BookshopS3Settings": {
|
|
||||||
"ServiceUrl": "http://192.168.1.177:30900",
|
|
||||||
"Region": "garage",
|
|
||||||
"BucketName": "bookshop",
|
|
||||||
"CdnBaseUrl": "https://bookshop.cdn.khongisa.co.za"
|
|
||||||
},
|
|
||||||
"BookshopQuotesS3Settings": {
|
|
||||||
"ServiceUrl": "http://192.168.1.177:30900",
|
|
||||||
"Region": "garage",
|
|
||||||
"BucketName": "bookshop.quotes",
|
|
||||||
"CdnBaseUrl": "https://bookshop.quotes.cdn.khongisa.co.za"
|
|
||||||
},
|
|
||||||
"Email": {
|
|
||||||
"Credentials": {
|
|
||||||
"Username": "shop@litecharms.co.za"
|
|
||||||
},
|
|
||||||
"Port": 465,
|
|
||||||
"Host": "mail.litecharms.co.za",
|
|
||||||
"UseSsl": true
|
|
||||||
},
|
|
||||||
"Monitoring": {
|
|
||||||
"ApiKey": "",
|
|
||||||
"Address": "http://aspire-dashboard-service.aspire.svc.cluster.local:18889",
|
|
||||||
"ServiceName": "LiteCharms.LeadGenerator"
|
|
||||||
},
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
using LiteCharms.Features.MidrandBooks.HealthChecks;
|
|
||||||
using static LiteCharms.Features.Extensions.Postgres;
|
|
||||||
using static LiteCharms.Features.MidrandBooks.Extensions.Postgres;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.MidrandBooks.Extensions;
|
|
||||||
|
|
||||||
public static class HealthChecks
|
|
||||||
{
|
|
||||||
public static IServiceCollection AddMidrandShopQuartzHealthCheck(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddHealthChecks().AddCheck<MidrandShopQuartzHealthCheck>(SchedulerDbConfigName);
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IServiceCollection AddMidrandShopPostgresHealthCheck(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddHealthChecks().AddCheck<PostgresMidrandShopHealthCheck>(MidrandShopDbConfigName);
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IServiceCollection AddHealthChecksSupport(this IServiceCollection services, IConfiguration configuration)
|
|
||||||
{
|
|
||||||
services.AddHealthChecks()
|
|
||||||
.AddCheck("Self", () => HealthCheckResult.Healthy());
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using LiteCharms.Features.MidrandBooks.Postgres;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.MidrandBooks.Extensions;
|
|
||||||
|
|
||||||
public static class Postgres
|
|
||||||
{
|
|
||||||
public const string MidrandShopDbConfigName = "PostgresMidrandShop";
|
|
||||||
|
|
||||||
public static IServiceCollection AddMidrandShopDatabase(this IServiceCollection services, IConfiguration configuration)
|
|
||||||
{
|
|
||||||
services.AddPooledDbContextFactory<MidrandShopDbContext>(options =>
|
|
||||||
options.UseNpgsql(configuration.GetConnectionString(MidrandShopDbConfigName)));
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
using static LiteCharms.Features.Extensions.Quartz;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.MidrandBooks.HealthChecks;
|
|
||||||
|
|
||||||
public class MidrandShopQuartzHealthCheck(ISchedulerFactory schedulerFactory) : IHealthCheck
|
|
||||||
{
|
|
||||||
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var scheduler = await schedulerFactory.GetScheduler(MidrandShopSchedulerName, cancellationToken);
|
|
||||||
|
|
||||||
if(scheduler == null)
|
|
||||||
return HealthCheckResult.Unhealthy($"Scheduler with name '{MidrandShopSchedulerName}' not found.");
|
|
||||||
|
|
||||||
if (!scheduler.IsStarted)
|
|
||||||
return HealthCheckResult.Unhealthy($"{MidrandShopSchedulerName} Quartz scheduler is not running");
|
|
||||||
|
|
||||||
await scheduler.CheckExists(new JobKey(Guid.NewGuid().ToString()), cancellationToken);
|
|
||||||
|
|
||||||
return HealthCheckResult.Healthy($"{MidrandShopSchedulerName} Quartz scheduler is ready");
|
|
||||||
}
|
|
||||||
catch (SchedulerException)
|
|
||||||
{
|
|
||||||
return HealthCheckResult.Unhealthy($"{MidrandShopSchedulerName} Quartz scheduler cannot connect to the store");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
using static LiteCharms.Features.MidrandBooks.Extensions.Postgres;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.MidrandBooks.HealthChecks;
|
|
||||||
|
|
||||||
public class PostgresMidrandShopHealthCheck(IConfiguration configuration) : IHealthCheck
|
|
||||||
{
|
|
||||||
private readonly string connectionString = configuration.GetConnectionString(MidrandShopDbConfigName)!;
|
|
||||||
|
|
||||||
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await using var dataSource = NpgsqlDataSource.Create(connectionString);
|
|
||||||
await using var connection = await dataSource.OpenConnectionAsync(cancellationToken);
|
|
||||||
|
|
||||||
await using var command = connection.CreateCommand();
|
|
||||||
command.CommandText = "SELECT 1";
|
|
||||||
|
|
||||||
await command.ExecuteScalarAsync(cancellationToken);
|
|
||||||
|
|
||||||
return HealthCheckResult.Healthy($"{MidrandShopDbConfigName} is responsive.");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return HealthCheckResult.Unhealthy($"{MidrandShopDbConfigName} is unreachable.", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<SignAssembly>True</SignAssembly>
|
|
||||||
<AssemblyOriginatorKeyFile>..\LiteCharms.snk</AssemblyOriginatorKeyFile>
|
|
||||||
<UserSecretsId>5be62f49-3ed0-4468-884e-1b04e048b45a</UserSecretsId>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!-- Nuget Package Details -->
|
|
||||||
<PropertyGroup>
|
|
||||||
<PackageId>LiteCharms.Features.MidrandBooks</PackageId>
|
|
||||||
<Version>1.0.20</Version>
|
|
||||||
<Authors>Khwezi Mngoma</Authors>
|
|
||||||
<Company>Lite Charms (PTY) Ltd</Company>
|
|
||||||
<Description>MidrandBooks feature components for Lite Charms applications.</Description>
|
|
||||||
<PackageProjectUrl>https://gitea.khongisa.co.za/litecharms/components</PackageProjectUrl>
|
|
||||||
<RepositoryUrl>https://gitea.khongisa.co.za/litecharms/components.git</RepositoryUrl>
|
|
||||||
<RepositoryType>git</RepositoryType>
|
|
||||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
|
||||||
<PackageTags>utility;dotnet</PackageTags>
|
|
||||||
<PackageIcon>icon.png</PackageIcon>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="..\LICENSE" Pack="true" PackagePath="\" />
|
|
||||||
<None Include="..\icon.png" Pack="true" PackagePath="\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Quartz Scheduler-->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="OpenTelemetry" Version="1.15.3" />
|
|
||||||
<PackageReference Include="Quartz" Version="3.18.1" />
|
|
||||||
<PackageReference Include="Quartz.Plugins" Version="3.18.1" />
|
|
||||||
<PackageReference Include="Quartz.Plugins.TimeZoneConverter" Version="3.18.1" />
|
|
||||||
<PackageReference Include="Quartz.Serialization.SystemTextJson" Version="3.18.1" />
|
|
||||||
<PackageReference Include="Quartz.AspNetCore" Version="3.18.1" />
|
|
||||||
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.18.1" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="Quartz" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Configuration -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.8" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="Microsoft.Extensions.Configuration" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Health Checks -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Core" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Data" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="9.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="10.0.8" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
|
|
||||||
<Using Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Open Telemetry -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.3" />
|
|
||||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.15.3" />
|
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.15.2" />
|
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.15.1" />
|
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.15.1" />
|
|
||||||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.15.3" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="OpenTelemetry.Resources" />
|
|
||||||
<Using Include="OpenTelemetry.Exporter" />
|
|
||||||
<Using Include="OpenTelemetry.Logs" />
|
|
||||||
<Using Include="OpenTelemetry.Metrics" />
|
|
||||||
<Using Include="OpenTelemetry.Trace" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Database -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.8">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.8">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="Npgsql" />
|
|
||||||
<Using Include="Microsoft.EntityFrameworkCore" />
|
|
||||||
<Using Include="Microsoft.EntityFrameworkCore.Design" />
|
|
||||||
<Using Include="Microsoft.EntityFrameworkCore.Metadata.Builders" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Email -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="MailKit" Version="4.16.0" />
|
|
||||||
<PackageReference Include="MimeKit" Version="4.16.0" />
|
|
||||||
|
|
||||||
<!-- Global Usings-->
|
|
||||||
<Using Include="MimeKit" />
|
|
||||||
<Using Include="MailKit.Net.Smtp" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- CQRS -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="FluentResults" Version="4.0.0" />
|
|
||||||
<PackageReference Include="Mediator.Abstractions" Version="3.0.2" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="FluentResults" />
|
|
||||||
<Using Include="Mediator" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Amazon S3 SDK -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.1" />
|
|
||||||
<PackageReference Include="AWSSDK.S3" Version="4.0.23.4" />
|
|
||||||
<ProjectReference Include="..\LiteCharms.Features\LiteCharms.Features.csproj" />
|
|
||||||
|
|
||||||
<!-- global Usings -->
|
|
||||||
<Using Include="Amazon.S3" />
|
|
||||||
<Using Include="Amazon.S3.Model" />
|
|
||||||
<Using Include="Amazon.Runtime" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Shared Usings -->
|
|
||||||
<ItemGroup>
|
|
||||||
<Using Include="Microsoft.AspNetCore.Builder" />
|
|
||||||
<Using Include="Microsoft.Extensions.Hosting" />
|
|
||||||
<Using Include="System.Text" />
|
|
||||||
<Using Include="System.Text.Json" />
|
|
||||||
<Using Include="System.Threading.Channels" />
|
|
||||||
<Using Include="System.Collections.ObjectModel" />
|
|
||||||
<Using Include="System.Diagnostics" />
|
|
||||||
<Using Include="System.Diagnostics.Metrics" />
|
|
||||||
<Using Include="Microsoft.Extensions.DependencyInjection" />
|
|
||||||
<Using Include="System.Security.Cryptography" />
|
|
||||||
<Using Include="Microsoft.Extensions.Options" />
|
|
||||||
<Using Include="Microsoft.Extensions.Logging" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace LiteCharms.Features.MidrandBooks.Postgres;
|
|
||||||
|
|
||||||
public class MidrandShopDbContext(DbContextOptions<MidrandShopDbContext> options) : DbContext(options)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using static LiteCharms.Features.MidrandBooks.Extensions.Postgres;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.MidrandBooks.Postgres;
|
|
||||||
|
|
||||||
public class MidrandShopDbContextFactory : IDesignTimeDbContextFactory<MidrandShopDbContext>
|
|
||||||
{
|
|
||||||
public MidrandShopDbContext CreateDbContext(string[] args)
|
|
||||||
{
|
|
||||||
var configuration = new ConfigurationBuilder()
|
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
|
||||||
.AddUserSecrets(typeof(MidrandShopDbContext).Assembly)
|
|
||||||
.AddJsonFile("appsettings.json")
|
|
||||||
.AddEnvironmentVariables()
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
var optionsBuilder = new DbContextOptionsBuilder<MidrandShopDbContext>();
|
|
||||||
optionsBuilder.UseNpgsql(configuration.GetConnectionString(MidrandShopDbConfigName));
|
|
||||||
|
|
||||||
return new MidrandShopDbContext(optionsBuilder.Options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"Email": {
|
|
||||||
"Credentials": {
|
|
||||||
"Username": "shop@litecharms.co.za"
|
|
||||||
},
|
|
||||||
"Port": 465,
|
|
||||||
"Host": "mail.litecharms.co.za",
|
|
||||||
"UseSsl": true
|
|
||||||
},
|
|
||||||
"Monitoring": {
|
|
||||||
"ApiKey": "",
|
|
||||||
"Address": "http://aspire-dashboard-service.aspire.svc.cluster.local:18889",
|
|
||||||
"ServiceName": "LiteCharms.LeadGenerator"
|
|
||||||
},
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
|
||||||
using LiteCharms.Features.TechShop.Extensions;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Tests;
|
|
||||||
|
|
||||||
public class Fixture : IDisposable
|
|
||||||
{
|
|
||||||
public IConfiguration Configuration { get; set; }
|
|
||||||
|
|
||||||
public IServiceProvider Services { get; set; }
|
|
||||||
|
|
||||||
public IMediator Mediator { get; set; }
|
|
||||||
|
|
||||||
public Fixture()
|
|
||||||
{
|
|
||||||
Configuration = new ConfigurationBuilder()
|
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
|
||||||
.AddUserSecrets<Fixture>()
|
|
||||||
.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: true)
|
|
||||||
.AddEnvironmentVariables()
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
Services = new ServiceCollection()
|
|
||||||
.AddMediator()
|
|
||||||
.AddLogging()
|
|
||||||
.AddTechShopServices()
|
|
||||||
.AddEmailServiceBus()
|
|
||||||
.AddGarageS3(Configuration)
|
|
||||||
.AddTechShopDatabase(Configuration)
|
|
||||||
.AddEmailServices(Configuration)
|
|
||||||
.AddSingleton(Configuration)
|
|
||||||
.BuildServiceProvider();
|
|
||||||
|
|
||||||
Mediator = Services.GetRequiredService<IMediator>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() { }
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<IsPackable>false</IsPackable>
|
|
||||||
<UserSecretsId>fa06c1a6-2ba8-4c47-b19b-11e0f78e7b92</UserSecretsId>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="coverlet.collector" Version="10.0.1">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Mediator.SourceGenerator" Version="3.0.2">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
|
|
||||||
<PackageReference Include="xunit" Version="2.9.3" />
|
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<ItemGroup>
|
|
||||||
<Using Include="Mediator" />
|
|
||||||
<Using Include="Xunit.Abstractions" />
|
|
||||||
<Using Include="Microsoft.Extensions.DependencyInjection" />
|
|
||||||
<Using Include="Microsoft.Extensions.Configuration" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\LiteCharms.Features.TechShop\LiteCharms.Features.TechShop.csproj" />
|
|
||||||
<ProjectReference Include="..\LiteCharms.Features\LiteCharms.Features.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Using Include="Xunit" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
using LiteCharms.Features.Models;
|
|
||||||
using LiteCharms.Features.TechShop.Notifications;
|
|
||||||
using LiteCharms.Features.TechShop.Notifications.Events;
|
|
||||||
using static LiteCharms.Features.Extensions.Email;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Tests;
|
|
||||||
|
|
||||||
public class NotificationsFeatureTests(Fixture fixture, ITestOutputHelper output) : IClassFixture<Fixture>
|
|
||||||
{
|
|
||||||
private readonly NotificationService notificationService = fixture.Services.GetRequiredService<NotificationService>();
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task CreateNotificationCommand_ShouldSucceed()
|
|
||||||
{
|
|
||||||
Notifications.Models.CreateNotification request = new()
|
|
||||||
{
|
|
||||||
CorrelationId = Guid.CreateVersion7().ToString(),
|
|
||||||
CorrelationIdType = CorrelationIdTypes.None,
|
|
||||||
Direction = NotificationDirection.Outgoing,
|
|
||||||
Platform = NotificationPlatforms.Email,
|
|
||||||
Priority = Priorities.Medium,
|
|
||||||
Sender = "xUnit Test",
|
|
||||||
SenderAddress = "khwezi@mngoma.africa",
|
|
||||||
Recipient = $"{ShopEmailFromName} [Test]",
|
|
||||||
RecipientAddress = ShopEmailFromAddress,
|
|
||||||
Subject = "Test Message",
|
|
||||||
Message = "This is an automation test",
|
|
||||||
IsHtml = false,
|
|
||||||
IsInternal = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
var createResult = await notificationService.CreateNotificationAsync(request);
|
|
||||||
|
|
||||||
Assert.True(createResult.IsSuccess);
|
|
||||||
|
|
||||||
foreach (var error in createResult.Errors) output.WriteLine(error.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetNotifications_ShouldReturn_AllNotifications()
|
|
||||||
{
|
|
||||||
DateRange range = new()
|
|
||||||
{
|
|
||||||
From = DateOnly.FromDateTime(new DateTime(2026, 04, 01, 0, 0, 0, DateTimeKind.Utc)),
|
|
||||||
To = DateOnly.FromDateTime(DateTime.UtcNow),
|
|
||||||
MaxRecords = 10
|
|
||||||
};
|
|
||||||
|
|
||||||
var getResult = await notificationService.GetNotificationsAsync(range);
|
|
||||||
|
|
||||||
Assert.True(getResult.IsSuccess);
|
|
||||||
|
|
||||||
foreach (var error in getResult.Errors) output.WriteLine(error.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task ProcessEmailNotificationsEvent_ShouldSucceed()
|
|
||||||
{
|
|
||||||
var notification = ProcessEmailNotificationsEvent.Create();
|
|
||||||
|
|
||||||
await fixture.Mediator.Publish(notification);
|
|
||||||
|
|
||||||
Assert.True(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
using LiteCharms.Features.TechShop.Products;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Tests;
|
|
||||||
|
|
||||||
public class ProductsFeatureTests(Fixture fixture, ITestOutputHelper output) : IClassFixture<Fixture>
|
|
||||||
{
|
|
||||||
[Fact]
|
|
||||||
public async Task GetProductsAsync_ReturnsProducts()
|
|
||||||
{
|
|
||||||
var productService = fixture.Services.GetRequiredService<ProductService>();
|
|
||||||
|
|
||||||
var result = await productService.GetProductsAsync();
|
|
||||||
|
|
||||||
Assert.True(result.IsSuccess);
|
|
||||||
Assert.NotNull(result.Value);
|
|
||||||
|
|
||||||
output.WriteLine($"Retrieved {result.Value.Length} products.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"BookshopS3Settings": {
|
|
||||||
"ServiceUrl": "http://192.168.1.177:30900",
|
|
||||||
"Region": "garage",
|
|
||||||
"BucketName": "bookshop",
|
|
||||||
"CdnBaseUrl": "https://bookshop.cdn.khongisa.co.za"
|
|
||||||
},
|
|
||||||
"BookshopQuotesS3Settings": {
|
|
||||||
"ServiceUrl": "http://192.168.1.177:30900",
|
|
||||||
"Region": "garage",
|
|
||||||
"BucketName": "bookshop.quotes",
|
|
||||||
"CdnBaseUrl": "https://bookshop.quotes.cdn.khongisa.co.za"
|
|
||||||
},
|
|
||||||
"Email": {
|
|
||||||
"Credentials": {
|
|
||||||
"Username": "shop@litecharms.co.za"
|
|
||||||
},
|
|
||||||
"Port": 465,
|
|
||||||
"Host": "mail.litecharms.co.za",
|
|
||||||
"UseSsl": true
|
|
||||||
},
|
|
||||||
"Monitoring": {
|
|
||||||
"ApiKey": "",
|
|
||||||
"Address": "http://aspire-dashboard-service.aspire.svc.cluster.local:18889",
|
|
||||||
"ServiceName": "LiteCharms.LeadGenerator"
|
|
||||||
},
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
using LiteCharms.Features.TechShop.HealthChecks;
|
|
||||||
using static LiteCharms.Features.TechShop.Extensions.Postgres;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Extensions;
|
|
||||||
|
|
||||||
public static class HealthChecks
|
|
||||||
{
|
|
||||||
public static IServiceCollection AddShopQuartzHealthCheck(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddHealthChecks().AddCheck<ShopQuartzHealthCheck>("ShopQuartz");
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static IServiceCollection AddShopPostgresHealthCheck(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddHealthChecks().AddCheck<PostgresShopHealthCheck>(TechShopDbConfigName);
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using LiteCharms.Features.TechShop.Postgres;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Extensions;
|
|
||||||
|
|
||||||
public static class Postgres
|
|
||||||
{
|
|
||||||
public const string TechShopDbConfigName = "PostgresShop";
|
|
||||||
|
|
||||||
public static IServiceCollection AddTechShopDatabase(this IServiceCollection services, IConfiguration configuration)
|
|
||||||
{
|
|
||||||
services.AddPooledDbContextFactory<ShopDbContext>(options =>
|
|
||||||
options.UseNpgsql(configuration.GetConnectionString(TechShopDbConfigName)));
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
using LiteCharms.Features.TechShop.CartPackages;
|
|
||||||
using LiteCharms.Features.TechShop.Customers;
|
|
||||||
using LiteCharms.Features.TechShop.Leads;
|
|
||||||
using LiteCharms.Features.TechShop.Notifications;
|
|
||||||
using LiteCharms.Features.TechShop.Orders;
|
|
||||||
using LiteCharms.Features.TechShop.Products;
|
|
||||||
using LiteCharms.Features.TechShop.Quotes;
|
|
||||||
using LiteCharms.Features.TechShop.ShoppingCarts;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Extensions;
|
|
||||||
|
|
||||||
public static class Shop
|
|
||||||
{
|
|
||||||
public static IServiceCollection AddTechShopServices(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddSingleton<PackageService>()
|
|
||||||
.AddSingleton<LeadService>()
|
|
||||||
.AddSingleton<NotificationService>()
|
|
||||||
.AddSingleton<OrderService>()
|
|
||||||
.AddSingleton<ProductService>()
|
|
||||||
.AddSingleton<QuoteService>()
|
|
||||||
.AddSingleton<ShoppingCartService>()
|
|
||||||
.AddSingleton<CustomerService>();
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
using static LiteCharms.Features.Extensions.Quartz;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.HealthChecks;
|
|
||||||
|
|
||||||
public class ShopQuartzHealthCheck(ISchedulerFactory schedulerFactory) : IHealthCheck
|
|
||||||
{
|
|
||||||
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var scheduler = await schedulerFactory.GetScheduler(TechShopSchedulerName, cancellationToken);
|
|
||||||
|
|
||||||
if(scheduler == null)
|
|
||||||
return HealthCheckResult.Unhealthy($"Scheduler with name '{TechShopSchedulerName}' not found.");
|
|
||||||
|
|
||||||
if (!scheduler.IsStarted)
|
|
||||||
return HealthCheckResult.Unhealthy($"{TechShopSchedulerName} Quartz scheduler is not running");
|
|
||||||
|
|
||||||
await scheduler.CheckExists(new JobKey(Guid.NewGuid().ToString()), cancellationToken);
|
|
||||||
|
|
||||||
return HealthCheckResult.Healthy($"{TechShopSchedulerName} Quartz scheduler is ready");
|
|
||||||
}
|
|
||||||
catch (SchedulerException)
|
|
||||||
{
|
|
||||||
return HealthCheckResult.Unhealthy($"{TechShopSchedulerName} Quartz scheduler cannot connect to the store");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<SignAssembly>True</SignAssembly>
|
|
||||||
<AssemblyOriginatorKeyFile>..\LiteCharms.snk</AssemblyOriginatorKeyFile>
|
|
||||||
<UserSecretsId>fbd8f4a2-0420-44e2-baff-4678d9e7eee1</UserSecretsId>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!-- Nuget Package Details -->
|
|
||||||
<PropertyGroup>
|
|
||||||
<PackageId>LiteCharms.Features.TechShop</PackageId>
|
|
||||||
<Version>1.0.20</Version>
|
|
||||||
<Authors>Khwezi Mngoma</Authors>
|
|
||||||
<Company>Lite Charms (PTY) Ltd</Company>
|
|
||||||
<Description>TechShop feature components for Lite Charms applications.</Description>
|
|
||||||
<PackageProjectUrl>https://gitea.khongisa.co.za/litecharms/components</PackageProjectUrl>
|
|
||||||
<RepositoryUrl>https://gitea.khongisa.co.za/litecharms/components.git</RepositoryUrl>
|
|
||||||
<RepositoryType>git</RepositoryType>
|
|
||||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
|
||||||
<PackageTags>utility;dotnet</PackageTags>
|
|
||||||
<PackageIcon>icon.png</PackageIcon>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="..\LICENSE" Pack="true" PackagePath="\" />
|
|
||||||
<None Include="..\icon.png" Pack="true" PackagePath="\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Quartz Scheduler-->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="OpenTelemetry" Version="1.15.3" />
|
|
||||||
<PackageReference Include="Quartz" Version="3.18.1" />
|
|
||||||
<PackageReference Include="Quartz.Plugins" Version="3.18.1" />
|
|
||||||
<PackageReference Include="Quartz.Plugins.TimeZoneConverter" Version="3.18.1" />
|
|
||||||
<PackageReference Include="Quartz.Serialization.SystemTextJson" Version="3.18.1" />
|
|
||||||
<PackageReference Include="Quartz.AspNetCore" Version="3.18.1" />
|
|
||||||
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.18.1" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="Quartz" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Configuration -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.8" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="Microsoft.Extensions.Configuration" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Health Checks -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Core" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Data" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="9.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="10.0.8" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
|
|
||||||
<Using Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Open Telemetry -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.3" />
|
|
||||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.15.3" />
|
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.15.2" />
|
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.15.1" />
|
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.15.1" />
|
|
||||||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.15.3" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="OpenTelemetry.Resources" />
|
|
||||||
<Using Include="OpenTelemetry.Exporter" />
|
|
||||||
<Using Include="OpenTelemetry.Logs" />
|
|
||||||
<Using Include="OpenTelemetry.Metrics" />
|
|
||||||
<Using Include="OpenTelemetry.Trace" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Database -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.8">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.8">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="Npgsql" />
|
|
||||||
<Using Include="Microsoft.EntityFrameworkCore" />
|
|
||||||
<Using Include="Microsoft.EntityFrameworkCore.Design" />
|
|
||||||
<Using Include="Microsoft.EntityFrameworkCore.Metadata.Builders" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Email -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="MailKit" Version="4.16.0" />
|
|
||||||
<PackageReference Include="MimeKit" Version="4.16.0" />
|
|
||||||
|
|
||||||
<!-- Global Usings-->
|
|
||||||
<Using Include="MimeKit" />
|
|
||||||
<Using Include="MailKit.Net.Smtp" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- CQRS -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="FluentResults" Version="4.0.0" />
|
|
||||||
<PackageReference Include="Mediator.Abstractions" Version="3.0.2" />
|
|
||||||
|
|
||||||
<!-- Global Usings -->
|
|
||||||
<Using Include="FluentResults" />
|
|
||||||
<Using Include="Mediator" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Amazon S3 SDK -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.1" />
|
|
||||||
<PackageReference Include="AWSSDK.S3" Version="4.0.23.4" />
|
|
||||||
<ProjectReference Include="..\LiteCharms.Features\LiteCharms.Features.csproj" />
|
|
||||||
|
|
||||||
<!-- global Usings -->
|
|
||||||
<Using Include="Amazon.S3" />
|
|
||||||
<Using Include="Amazon.S3.Model" />
|
|
||||||
<Using Include="Amazon.Runtime" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Shared Usings -->
|
|
||||||
<ItemGroup>
|
|
||||||
<Using Include="Microsoft.AspNetCore.Builder" />
|
|
||||||
<Using Include="Microsoft.Extensions.Hosting" />
|
|
||||||
<Using Include="System.Text" />
|
|
||||||
<Using Include="System.Text.Json" />
|
|
||||||
<Using Include="System.Threading.Channels" />
|
|
||||||
<Using Include="System.Collections.ObjectModel" />
|
|
||||||
<Using Include="System.Diagnostics" />
|
|
||||||
<Using Include="System.Diagnostics.Metrics" />
|
|
||||||
<Using Include="Microsoft.Extensions.DependencyInjection" />
|
|
||||||
<Using Include="System.Security.Cryptography" />
|
|
||||||
<Using Include="Microsoft.Extensions.Options" />
|
|
||||||
<Using Include="Microsoft.Extensions.Logging" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
Generated
-788
@@ -1,788 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
|
||||||
using LiteCharms.Features.TechShop.Products.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(ShopDbContext))]
|
|
||||||
[Migration("20260520191059_AddedProductMetadata")]
|
|
||||||
partial class AddedProductMetadata
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "10.0.8")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.CartPackages.Entities.Package", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<bool>("Active")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(2048)
|
|
||||||
.HasColumnType("character varying(2048)");
|
|
||||||
|
|
||||||
b.Property<string>("ImageUrl")
|
|
||||||
.HasMaxLength(2048)
|
|
||||||
.HasColumnType("character varying(2048)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Summary")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(512)
|
|
||||||
.HasColumnType("character varying(512)");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Package", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.CartPackages.Entities.PackageItem", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<bool>("Active")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<Guid>("PackageId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("ProductPriceId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("PackageId");
|
|
||||||
|
|
||||||
b.HasIndex("ProductPriceId");
|
|
||||||
|
|
||||||
b.ToTable("PackageItem", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Customers.Entities.Customer", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<bool>("Active")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("boolean")
|
|
||||||
.HasDefaultValue(true);
|
|
||||||
|
|
||||||
b.Property<string>("Address")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("City")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Company")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Country")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<string>("Discord")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LinkedIn")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Phone")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PostalCode")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Region")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Slack")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Tax")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("Website")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Whatsapp")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Customers", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Leads.Entities.Lead", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<long?>("AdGroupId")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<long?>("AdName")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<string>("AppClickId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("AttributionHash")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<long?>("CampaignId")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<string>("ClickId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ClickLocation")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<Guid?>("CustomerId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<long?>("FeedItemId")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<string>("Source")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<long?>("TargetId")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("WebClickId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("CustomerId");
|
|
||||||
|
|
||||||
b.ToTable("Leads", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Notifications.Entities.Notification", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("CorrelationId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("CorrelationIdType")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<int>("Direction")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.PrimitiveCollection<string>("Errors")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<bool>("HasError")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("boolean")
|
|
||||||
.HasDefaultValue(false);
|
|
||||||
|
|
||||||
b.Property<bool>("IsHtml")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("boolean")
|
|
||||||
.HasDefaultValue(false);
|
|
||||||
|
|
||||||
b.Property<bool>("IsInternal")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("boolean")
|
|
||||||
.HasDefaultValue(true);
|
|
||||||
|
|
||||||
b.Property<string>("Message")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("Platform")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("Priority")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<bool>("Processed")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("boolean")
|
|
||||||
.HasDefaultValue(false);
|
|
||||||
|
|
||||||
b.Property<string>("RecipientAddress")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("RecipientName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SenderAddress")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SenderName")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Subject")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Notification", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Orders.Entities.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<Guid>("CustomerId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("InvoiceUrl")
|
|
||||||
.HasMaxLength(2048)
|
|
||||||
.HasColumnType("character varying(2048)");
|
|
||||||
|
|
||||||
b.PrimitiveCollection<string>("Notes")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.PrimitiveCollection<string>("Requirements")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.PrimitiveCollection<string>("Terms")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("CustomerId");
|
|
||||||
|
|
||||||
b.ToTable("Orders", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Orders.Entities.OrderRefund", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<decimal>("Amount")
|
|
||||||
.HasPrecision(18, 2)
|
|
||||||
.HasColumnType("numeric(18,2)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<Guid>("OrderId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Reason")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("OrderId");
|
|
||||||
|
|
||||||
b.ToTable("OrderRefunds", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Products.Entities.Product", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<bool>("Active")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("boolean")
|
|
||||||
.HasDefaultValue(false);
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(2048)
|
|
||||||
.HasColumnType("character varying(2048)");
|
|
||||||
|
|
||||||
b.Property<string>("ImageUrl")
|
|
||||||
.HasMaxLength(2048)
|
|
||||||
.HasColumnType("character varying(2048)");
|
|
||||||
|
|
||||||
b.Property<ProductMetadata>("Metadata")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Summary")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(512)
|
|
||||||
.HasColumnType("character varying(512)");
|
|
||||||
|
|
||||||
b.PrimitiveCollection<string>("Thumbnails")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Products", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Products.Entities.ProductPrice", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<bool>("Active")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<decimal>("Discount")
|
|
||||||
.HasPrecision(18, 2)
|
|
||||||
.HasColumnType("numeric(18,2)");
|
|
||||||
|
|
||||||
b.Property<decimal>("Price")
|
|
||||||
.HasPrecision(18, 2)
|
|
||||||
.HasColumnType("numeric(18,2)");
|
|
||||||
|
|
||||||
b.Property<Guid>("ProductId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ProductId");
|
|
||||||
|
|
||||||
b.ToTable("ProductPrices", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Quotes.Entities.Quote", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<Guid>("CustomerId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("ExpiredAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("InvoiceUrl")
|
|
||||||
.HasMaxLength(2048)
|
|
||||||
.HasColumnType("character varying(2048)");
|
|
||||||
|
|
||||||
b.Property<Guid?>("OrderId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Reason")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<Guid?>("ShoppingCartId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("CustomerId");
|
|
||||||
|
|
||||||
b.HasIndex("OrderId")
|
|
||||||
.IsUnique();
|
|
||||||
|
|
||||||
b.HasIndex("ShoppingCartId")
|
|
||||||
.IsUnique();
|
|
||||||
|
|
||||||
b.ToTable("Quotes", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCart", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<Guid>("CustomerId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid?>("OrderId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("CustomerId");
|
|
||||||
|
|
||||||
b.HasIndex("OrderId")
|
|
||||||
.IsUnique();
|
|
||||||
|
|
||||||
b.ToTable("ShoppingCarts", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCartItem", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<Guid>("ProductPriceId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<int>("Quantity")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasDefaultValue(1);
|
|
||||||
|
|
||||||
b.Property<Guid>("ShoppingCartId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ProductPriceId");
|
|
||||||
|
|
||||||
b.HasIndex("ShoppingCartId");
|
|
||||||
|
|
||||||
b.ToTable("ShoppingCartItems", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCartPackage", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<Guid>("PackageId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("ShoppingCartId")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("PackageId");
|
|
||||||
|
|
||||||
b.HasIndex("ShoppingCartId");
|
|
||||||
|
|
||||||
b.ToTable("ShoppingCartPackages", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.CartPackages.Entities.PackageItem", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.CartPackages.Entities.Package", "Package")
|
|
||||||
.WithMany("PackageItems")
|
|
||||||
.HasForeignKey("PackageId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.Products.Entities.ProductPrice", "ProductPrice")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ProductPriceId")
|
|
||||||
.OnDelete(DeleteBehavior.Restrict)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Package");
|
|
||||||
|
|
||||||
b.Navigation("ProductPrice");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Leads.Entities.Lead", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.Customers.Entities.Customer", "Customer")
|
|
||||||
.WithMany("Leads")
|
|
||||||
.HasForeignKey("CustomerId")
|
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
|
||||||
|
|
||||||
b.Navigation("Customer");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Orders.Entities.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.Customers.Entities.Customer", "Customer")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("CustomerId")
|
|
||||||
.OnDelete(DeleteBehavior.Restrict)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Customer");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Orders.Entities.OrderRefund", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.Orders.Entities.Order", "Order")
|
|
||||||
.WithMany("Refunds")
|
|
||||||
.HasForeignKey("OrderId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Order");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Products.Entities.ProductPrice", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.Products.Entities.Product", "Product")
|
|
||||||
.WithMany("ProductPrices")
|
|
||||||
.HasForeignKey("ProductId")
|
|
||||||
.OnDelete(DeleteBehavior.Restrict)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Product");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Quotes.Entities.Quote", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.Customers.Entities.Customer", "Customer")
|
|
||||||
.WithMany("Quotes")
|
|
||||||
.HasForeignKey("CustomerId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.Orders.Entities.Order", "Order")
|
|
||||||
.WithOne("Quote")
|
|
||||||
.HasForeignKey("LiteCharms.Features.Shop.Quotes.Entities.Quote", "OrderId");
|
|
||||||
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCart", "ShoppingCart")
|
|
||||||
.WithOne("Quote")
|
|
||||||
.HasForeignKey("LiteCharms.Features.Shop.Quotes.Entities.Quote", "ShoppingCartId");
|
|
||||||
|
|
||||||
b.Navigation("Customer");
|
|
||||||
|
|
||||||
b.Navigation("Order");
|
|
||||||
|
|
||||||
b.Navigation("ShoppingCart");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCart", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.Customers.Entities.Customer", "Customer")
|
|
||||||
.WithMany("ShoppingCarts")
|
|
||||||
.HasForeignKey("CustomerId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.Orders.Entities.Order", "Order")
|
|
||||||
.WithOne("ShoppingCart")
|
|
||||||
.HasForeignKey("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCart", "OrderId")
|
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
|
||||||
|
|
||||||
b.Navigation("Customer");
|
|
||||||
|
|
||||||
b.Navigation("Order");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCartItem", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.Products.Entities.ProductPrice", "ProductPrice")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ProductPriceId")
|
|
||||||
.OnDelete(DeleteBehavior.Restrict)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCart", "ShoppingCart")
|
|
||||||
.WithMany("ShoppingCartItems")
|
|
||||||
.HasForeignKey("ShoppingCartId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("ProductPrice");
|
|
||||||
|
|
||||||
b.Navigation("ShoppingCart");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCartPackage", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.CartPackages.Entities.Package", "Package")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("PackageId")
|
|
||||||
.OnDelete(DeleteBehavior.Restrict)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCart", "ShoppingCart")
|
|
||||||
.WithMany("ShoppingCartPackages")
|
|
||||||
.HasForeignKey("ShoppingCartId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Package");
|
|
||||||
|
|
||||||
b.Navigation("ShoppingCart");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.CartPackages.Entities.Package", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("PackageItems");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Customers.Entities.Customer", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Leads");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
|
|
||||||
b.Navigation("Quotes");
|
|
||||||
|
|
||||||
b.Navigation("ShoppingCarts");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Orders.Entities.Order", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Quote");
|
|
||||||
|
|
||||||
b.Navigation("Refunds");
|
|
||||||
|
|
||||||
b.Navigation("ShoppingCart");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.Products.Entities.Product", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("ProductPrices");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.Shop.ShoppingCarts.Entities.ShoppingCart", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Quote");
|
|
||||||
|
|
||||||
b.Navigation("ShoppingCartItems");
|
|
||||||
|
|
||||||
b.Navigation("ShoppingCartPackages");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-71
@@ -1,71 +0,0 @@
|
|||||||
using System;
|
|
||||||
using LiteCharms.Features.TechShop.Products.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class AddedProductMetadata : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<bool>(
|
|
||||||
name: "Active",
|
|
||||||
table: "Products",
|
|
||||||
type: "boolean",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false,
|
|
||||||
oldClrType: typeof(bool),
|
|
||||||
oldType: "boolean",
|
|
||||||
oldDefaultValue: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
|
||||||
name: "CreatedAt",
|
|
||||||
table: "Products",
|
|
||||||
type: "timestamp with time zone",
|
|
||||||
nullable: false,
|
|
||||||
defaultValueSql: "now()");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<ProductMetadata>(
|
|
||||||
name: "Metadata",
|
|
||||||
table: "Products",
|
|
||||||
type: "jsonb",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
|
||||||
name: "UpdatedAt",
|
|
||||||
table: "Products",
|
|
||||||
type: "timestamp with time zone",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CreatedAt",
|
|
||||||
table: "Products");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Metadata",
|
|
||||||
table: "Products");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "UpdatedAt",
|
|
||||||
table: "Products");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<bool>(
|
|
||||||
name: "Active",
|
|
||||||
table: "Products",
|
|
||||||
type: "boolean",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: true,
|
|
||||||
oldClrType: typeof(bool),
|
|
||||||
oldType: "boolean",
|
|
||||||
oldDefaultValue: false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
using LiteCharms.Features.TechShop.CartPackages.Entities;
|
|
||||||
using LiteCharms.Features.TechShop.Customers.Entities;
|
|
||||||
using LiteCharms.Features.TechShop.Leads.Entities;
|
|
||||||
using LiteCharms.Features.TechShop.Notifications.Entities;
|
|
||||||
using LiteCharms.Features.TechShop.Orders.Entities;
|
|
||||||
using LiteCharms.Features.TechShop.Products.Entities;
|
|
||||||
using LiteCharms.Features.TechShop.Quotes.Entities;
|
|
||||||
using LiteCharms.Features.TechShop.ShoppingCarts.Entities;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Postgres;
|
|
||||||
|
|
||||||
public class ShopDbContext(DbContextOptions<ShopDbContext> options) : DbContext(options)
|
|
||||||
{
|
|
||||||
public DbSet<Customer> Customers { get; set; }
|
|
||||||
|
|
||||||
public DbSet<Lead> Leads { get; set; }
|
|
||||||
|
|
||||||
public DbSet<Order> Orders { get; set; }
|
|
||||||
|
|
||||||
public DbSet<OrderRefund> OrderRefunds { get; set; }
|
|
||||||
|
|
||||||
public DbSet<Product> Products { get; set; }
|
|
||||||
|
|
||||||
public DbSet<ProductPrice> ProductPrices { get; set; }
|
|
||||||
|
|
||||||
public DbSet<Notification> Notifications { get; set; }
|
|
||||||
|
|
||||||
public DbSet<Quote> Quotes { get; set; }
|
|
||||||
|
|
||||||
public DbSet<ShoppingCart> ShoppingCarts { get; set; }
|
|
||||||
|
|
||||||
public DbSet<ShoppingCartItem> ShoppingCartItems { get; set; }
|
|
||||||
|
|
||||||
public DbSet<Package> Packages { get; set; }
|
|
||||||
|
|
||||||
public DbSet<PackageItem> PackageItems { get; set; }
|
|
||||||
|
|
||||||
public DbSet<ShoppingCartPackage> ShoppingCartPackages { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Products.Models;
|
|
||||||
|
|
||||||
public class CreateProductModel
|
|
||||||
{
|
|
||||||
[MaxLength(128)]
|
|
||||||
[Required(ErrorMessage = "Product name is required.")]
|
|
||||||
public string? Name { get; set; }
|
|
||||||
|
|
||||||
[MaxLength(512)]
|
|
||||||
[Required(ErrorMessage = "Summary is required.")]
|
|
||||||
public string? Summary { get; set; }
|
|
||||||
|
|
||||||
[MaxLength(2048)]
|
|
||||||
[Required(ErrorMessage = "Description is required.")]
|
|
||||||
public string? Description { get; set; }
|
|
||||||
|
|
||||||
[Range(0.01, double.MaxValue, ErrorMessage = "Price must be greater than zero.")]
|
|
||||||
public decimal Price { get; set; }
|
|
||||||
|
|
||||||
[MaxLength(128)]
|
|
||||||
[Required(ErrorMessage = "Author metadata is required.")]
|
|
||||||
public string? Author { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Publication Date is required.")]
|
|
||||||
public DateTime PublishDate { get; set; } = DateTime.Today;
|
|
||||||
|
|
||||||
[MaxLength(255)]
|
|
||||||
[Required(ErrorMessage = "Copyright Information field is required.")]
|
|
||||||
public string? CopyrightInfo { get; set; }
|
|
||||||
|
|
||||||
[MaxLength(128)]
|
|
||||||
[Required(ErrorMessage = "ISBN code is required.")]
|
|
||||||
[RegularExpression(@"^(?=(?:\D*\d){10}(?:(?:\D*\d){3})?$)[\d-]+$", ErrorMessage = "Please enter a valid ISBN-10 or ISBN-13 string.")]
|
|
||||||
public string? Isbn { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Primary image is required.")]
|
|
||||||
public string? ImageUrl { get; set; }
|
|
||||||
|
|
||||||
public List<string> Thumbnails { get; set; } = [];
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Products.Models;
|
|
||||||
|
|
||||||
public class ProductMetadata
|
|
||||||
{
|
|
||||||
public string? Manufacturer { get; set; }
|
|
||||||
|
|
||||||
public string? ManufactureDate { get; set; }
|
|
||||||
|
|
||||||
public string? CopyrightInfo { get; set; }
|
|
||||||
|
|
||||||
public string? SerialNumber { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"Email": {
|
|
||||||
"Credentials": {
|
|
||||||
"Username": "shop@litecharms.co.za"
|
|
||||||
},
|
|
||||||
"Port": 465,
|
|
||||||
"Host": "mail.litecharms.co.za",
|
|
||||||
"UseSsl": true
|
|
||||||
},
|
|
||||||
"Monitoring": {
|
|
||||||
"ApiKey": "",
|
|
||||||
"Address": "http://aspire-dashboard-service.aspire.svc.cluster.local:18889",
|
|
||||||
"ServiceName": "LiteCharms.LeadGenerator"
|
|
||||||
},
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace LiteCharms.Features.Tests;
|
namespace LiteCharms.Features.Tests;
|
||||||
|
|
||||||
public class Fixture : IDisposable
|
public class CommonFixture : IDisposable
|
||||||
{
|
{
|
||||||
public IConfiguration Configuration { get; set; }
|
public IConfiguration Configuration { get; set; }
|
||||||
|
|
||||||
@@ -10,22 +10,22 @@ public class Fixture : IDisposable
|
|||||||
|
|
||||||
public IMediator Mediator { get; set; }
|
public IMediator Mediator { get; set; }
|
||||||
|
|
||||||
public Fixture()
|
public CommonFixture()
|
||||||
{
|
{
|
||||||
Configuration = new ConfigurationBuilder()
|
Configuration = new ConfigurationBuilder()
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
.AddUserSecrets<Fixture>()
|
.AddJsonFile("appsettings.json")
|
||||||
.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: true)
|
.AddUserSecrets<CommonFixture>()
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Services = new ServiceCollection()
|
Services = new ServiceCollection()
|
||||||
.AddMediator()
|
.AddMediator()
|
||||||
.AddLogging()
|
.AddLogging()
|
||||||
|
.AddShopServices()
|
||||||
.AddEmailServiceBus()
|
.AddEmailServiceBus()
|
||||||
.AddGarageS3(Configuration)
|
.AddShopDatabase(Configuration)
|
||||||
.AddEmailServices(Configuration)
|
.AddEmailServices(Configuration)
|
||||||
.AddSingleton(Configuration)
|
|
||||||
.BuildServiceProvider();
|
.BuildServiceProvider();
|
||||||
|
|
||||||
Mediator = Services.GetRequiredService<IMediator>();
|
Mediator = Services.GetRequiredService<IMediator>();
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="coverlet.collector" Version="10.0.1">
|
<PackageReference Include="coverlet.collector" Version="10.0.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
@@ -27,10 +27,10 @@
|
|||||||
|
|
||||||
<!-- Global Usings -->
|
<!-- Global Usings -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Using Include="Mediator" />
|
<Using Include="Mediator"/>
|
||||||
<Using Include="Xunit.Abstractions" />
|
<Using Include="Xunit.Abstractions"/>
|
||||||
<Using Include="Microsoft.Extensions.DependencyInjection" />
|
<Using Include="Microsoft.Extensions.DependencyInjection"/>
|
||||||
<Using Include="Microsoft.Extensions.Configuration" />
|
<Using Include="Microsoft.Extensions.Configuration"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="appsettings.json">
|
<None Update="appsettings.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using LiteCharms.Features.Shop.Notifications;
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.Tests;
|
||||||
|
|
||||||
|
public class NotificationsFeatureTests(CommonFixture fixture, ITestOutputHelper output) : IClassFixture<CommonFixture>
|
||||||
|
{
|
||||||
|
private readonly NotificationService notificationService = fixture.Services.GetRequiredService<NotificationService>();
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateNotificationCommand_ShouldSucceed()
|
||||||
|
{
|
||||||
|
Shop.Notifications.Models.CreateNotification request = new()
|
||||||
|
{
|
||||||
|
CorrelationId = Guid.CreateVersion7().ToString(),
|
||||||
|
CorrelationIdType = Shop.CorrelationIdTypes.None,
|
||||||
|
Direction = Shop.NotificationDirection.Outgoing,
|
||||||
|
Platform = Shop.NotificationPlatforms.Email,
|
||||||
|
Priority = Shop.Priorities.Medium,
|
||||||
|
Sender = "xUnit Test",
|
||||||
|
SenderAddress = "khwezi@mngoma.africa",
|
||||||
|
Recipient = $"{Email.Extensions.Constants.ShopEmailFromName} [Test]",
|
||||||
|
RecipientAddress = Email.Extensions.Constants.ShopEmailFromAddress,
|
||||||
|
Subject = "Test Message",
|
||||||
|
Message = "This is an automation test",
|
||||||
|
IsHtml = false,
|
||||||
|
IsInternal = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
var createResult = await notificationService.CreateNotificationAsync(request);
|
||||||
|
|
||||||
|
Assert.True(createResult.IsSuccess);
|
||||||
|
|
||||||
|
foreach (var error in createResult.Errors) output.WriteLine(error.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
using LiteCharms.Features.S3.Abstractions;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.Tests;
|
|
||||||
|
|
||||||
public class S3ServiceFeatureTests(Fixture fixture, ITestOutputHelper output) : IClassFixture<Fixture>
|
|
||||||
{
|
|
||||||
[Fact]
|
|
||||||
public async Task BookshopS3Service_MustReturnUrl()
|
|
||||||
{
|
|
||||||
var service = fixture.Services.GetKeyedService<IS3Service>(S3.Constants.BookshopBucketName);
|
|
||||||
|
|
||||||
var fileName = "appsettings.json";
|
|
||||||
|
|
||||||
string path = Path.Combine(Directory.GetCurrentDirectory(), fileName);
|
|
||||||
|
|
||||||
Assert.True(File.Exists(path));
|
|
||||||
|
|
||||||
var stream = File.OpenRead(path);
|
|
||||||
|
|
||||||
var result = await service!.UploadFileAsync(fileName, stream, MimeKit.MimeTypes.GetMimeType(fileName));
|
|
||||||
|
|
||||||
Assert.True(result.IsSuccess);
|
|
||||||
Assert.NotNull(result.Value);
|
|
||||||
Assert.NotEmpty(result.Value);
|
|
||||||
|
|
||||||
output.WriteLine(result.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task BookshopS3Service_MustDeleteFile()
|
|
||||||
{
|
|
||||||
var service = fixture.Services.GetKeyedService<IS3Service>(S3.Constants.BookshopBucketName);
|
|
||||||
|
|
||||||
var fileName = "appsettings.json";
|
|
||||||
|
|
||||||
string path = Path.Combine(Directory.GetCurrentDirectory(), fileName);
|
|
||||||
|
|
||||||
Assert.True(File.Exists(path));
|
|
||||||
|
|
||||||
var stream = File.OpenRead(path);
|
|
||||||
|
|
||||||
var uploadResult = await service!.UploadFileAsync(fileName, stream, MimeKit.MimeTypes.GetMimeType(fileName));
|
|
||||||
|
|
||||||
Assert.True(uploadResult.IsSuccess);
|
|
||||||
Assert.NotNull(uploadResult.Value);
|
|
||||||
Assert.NotEmpty(uploadResult.Value);
|
|
||||||
|
|
||||||
var fileKey = uploadResult.Value.Split('/').Last();
|
|
||||||
|
|
||||||
var deleteResult = await service!.DeleteFileAsync(fileKey);
|
|
||||||
|
|
||||||
Assert.True(deleteResult.IsSuccess);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,4 @@
|
|||||||
{
|
{
|
||||||
"BookshopS3Settings": {
|
|
||||||
"ServiceUrl": "http://192.168.1.177:30900",
|
|
||||||
"Region": "garage",
|
|
||||||
"BucketName": "bookshop",
|
|
||||||
"CdnBaseUrl": "https://bookshop.cdn.khongisa.co.za"
|
|
||||||
},
|
|
||||||
"BookshopQuotesS3Settings": {
|
|
||||||
"ServiceUrl": "http://192.168.1.177:30900",
|
|
||||||
"Region": "garage",
|
|
||||||
"BucketName": "bookshop.quotes",
|
|
||||||
"CdnBaseUrl": "https://bookshop.quotes.cdn.khongisa.co.za"
|
|
||||||
},
|
|
||||||
"Email": {
|
"Email": {
|
||||||
"Credentials": {
|
"Credentials": {
|
||||||
"Username": "shop@litecharms.co.za"
|
"Username": "shop@litecharms.co.za"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using LiteCharms.Features.Email.Configuration;
|
using LiteCharms.Features.Email.Configuration;
|
||||||
using LiteCharms.Features.Email.Extensions;
|
using LiteCharms.Features.Email.Extensions;
|
||||||
using LiteCharms.Features.Email.Models;
|
using LiteCharms.Features.Email.Models;
|
||||||
|
using LiteCharms.Features.Shop;
|
||||||
|
|
||||||
namespace LiteCharms.Features.Email;
|
namespace LiteCharms.Features.Email;
|
||||||
|
|
||||||
@@ -34,9 +35,8 @@ public class EmailService(IOptions<SmtpSettings> options) : IDisposable
|
|||||||
|
|
||||||
var bodyBuilder = new BodyBuilder();
|
var bodyBuilder = new BodyBuilder();
|
||||||
|
|
||||||
if (message.Body!.Properties.HasAttachments)
|
foreach (var attachment in message.Body?.Attachments!)
|
||||||
foreach (var attachment in message.Body?.Attachments!)
|
bodyBuilder.Attachments.Add(attachment.Name!, attachment.FileStream!, cancellationToken);
|
||||||
bodyBuilder.Attachments.Add(attachment.Name!, attachment.FileStream!, cancellationToken);
|
|
||||||
|
|
||||||
if (!message.Body.Properties.IsHtml) bodyBuilder.TextBody = message.Body.Message;
|
if (!message.Body.Properties.IsHtml) bodyBuilder.TextBody = message.Body.Message;
|
||||||
if (message.Body.Properties.IsHtml) bodyBuilder.HtmlBody = message.Body.Message;
|
if (message.Body.Properties.IsHtml) bodyBuilder.HtmlBody = message.Body.Message;
|
||||||
|
|||||||
+5
-3
@@ -1,12 +1,14 @@
|
|||||||
using static LiteCharms.Features.Extensions.Email;
|
using LiteCharms.Features.Shop;
|
||||||
|
using LiteCharms.Features.Shop.Notifications;
|
||||||
|
using static LiteCharms.Features.Email.Extensions.Constants;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Notifications.Events.Handlers;
|
namespace LiteCharms.Features.Email.Events.Handlers;
|
||||||
|
|
||||||
public class SendShopEmailEnquiryEventHandler(NotificationService notificationService) :
|
public class SendShopEmailEnquiryEventHandler(NotificationService notificationService) :
|
||||||
INotificationHandler<SendShopEmailEnquiryEvent>
|
INotificationHandler<SendShopEmailEnquiryEvent>
|
||||||
{
|
{
|
||||||
public async ValueTask Handle(SendShopEmailEnquiryEvent notification, CancellationToken cancellationToken) =>
|
public async ValueTask Handle(SendShopEmailEnquiryEvent notification, CancellationToken cancellationToken) =>
|
||||||
await notificationService.CreateNotificationAsync(new Models.CreateNotification
|
await notificationService.CreateNotificationAsync(new Shop.Notifications.Models.CreateNotification
|
||||||
{
|
{
|
||||||
CorrelationId = notification.CorrelationId,
|
CorrelationId = notification.CorrelationId,
|
||||||
CorrelationIdType = CorrelationIdTypes.None,
|
CorrelationIdType = CorrelationIdTypes.None,
|
||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
using LiteCharms.Features.Abstractions;
|
using LiteCharms.Features.Abstractions;
|
||||||
|
using LiteCharms.Features.Shop;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Notifications.Events;
|
namespace LiteCharms.Features.Email.Events;
|
||||||
|
|
||||||
public class SendShopEmailEnquiryEvent : EventBase, IEvent
|
public class SendShopEmailEnquiryEvent : EventBase, IEvent
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace LiteCharms.Features.Email.Extensions;
|
||||||
|
|
||||||
|
public static class Constants
|
||||||
|
{
|
||||||
|
public const string ShopSchedulerName = "shop";
|
||||||
|
public const string ShopEmailFromName = "Khongisa Shop";
|
||||||
|
public const string ShopEmailFromAddress = "shop@litecharms.co.za";
|
||||||
|
}
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace LiteCharms.Features.Email.Models;
|
namespace LiteCharms.Features.Email.Models;
|
||||||
|
|
||||||
public sealed class EmailEnquiryModel
|
public sealed class EmailEnquiry
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[MinLength(2)]
|
[MinLength(2)]
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace LiteCharms.Features.Email.Models;
|
using LiteCharms.Features.Shop;
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.Email.Models;
|
||||||
|
|
||||||
public class Response
|
public class Response
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
namespace LiteCharms.Features;
|
|
||||||
|
|
||||||
public enum EmailStatuses : int
|
|
||||||
{
|
|
||||||
GeneralError = 0,
|
|
||||||
AuthenticationError = 1,
|
|
||||||
ProtocolError = 2,
|
|
||||||
Connected = 3,
|
|
||||||
Disconnected = 4,
|
|
||||||
TooManyConnections = 5,
|
|
||||||
ConnectionAborted = 6,
|
|
||||||
Success = 7
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Priorities : int
|
|
||||||
{
|
|
||||||
Low = 0,
|
|
||||||
Medium = 1,
|
|
||||||
High = 2,
|
|
||||||
}
|
|
||||||
@@ -5,9 +5,6 @@ namespace LiteCharms.Features.Extensions;
|
|||||||
|
|
||||||
public static class Email
|
public static class Email
|
||||||
{
|
{
|
||||||
public const string ShopEmailFromName = "Khongisa Shop";
|
|
||||||
public const string ShopEmailFromAddress = "shop@litecharms.co.za";
|
|
||||||
|
|
||||||
public static IServiceCollection AddEmailServices(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddEmailServices(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
services.Configure<SmtpSettings>(configuration.GetSection("Email"));
|
services.Configure<SmtpSettings>(configuration.GetSection("Email"));
|
||||||
|
|||||||
+24
-27
@@ -1,18 +1,17 @@
|
|||||||
using LiteCharms.Features.TechShop.CartPackages.Models;
|
using LiteCharms.Features.Shop.CartPackages.Models;
|
||||||
using LiteCharms.Features.TechShop.Customers.Models;
|
using LiteCharms.Features.Shop.Customers.Models;
|
||||||
using LiteCharms.Features.TechShop.Leads.Models;
|
using LiteCharms.Features.Shop.Leads.Models;
|
||||||
using LiteCharms.Features.TechShop.Notifications.Models;
|
using LiteCharms.Features.Shop.Notifications.Models;
|
||||||
using LiteCharms.Features.TechShop.Orders.Models;
|
using LiteCharms.Features.Shop.Orders.Models;
|
||||||
using LiteCharms.Features.TechShop.Products.Entities;
|
using LiteCharms.Features.Shop.Products.Models;
|
||||||
using LiteCharms.Features.TechShop.Products.Models;
|
using LiteCharms.Features.Shop.Quotes.Models;
|
||||||
using LiteCharms.Features.TechShop.Quotes.Models;
|
using LiteCharms.Features.Shop.ShoppingCarts.Models;
|
||||||
using LiteCharms.Features.TechShop.ShoppingCarts.Models;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Extensions;
|
namespace LiteCharms.Features.Extensions;
|
||||||
|
|
||||||
public static class Mappers
|
public static class EntityModeMappers
|
||||||
{
|
{
|
||||||
public static ShoppingCartPackage ToModel(this ShoppingCarts.Entities.ShoppingCartPackage entity) =>
|
public static ShoppingCartPackage ToModel(this Features.Shop.ShoppingCarts.Entities.ShoppingCartPackage entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -21,7 +20,7 @@ public static class Mappers
|
|||||||
ShoppingCartId = entity.ShoppingCartId
|
ShoppingCartId = entity.ShoppingCartId
|
||||||
};
|
};
|
||||||
|
|
||||||
public static PackageItem ToModel(this CartPackages.Entities.PackageItem entity) =>
|
public static PackageItem ToModel(this Features.Shop.CartPackages.Entities.PackageItem entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -31,7 +30,7 @@ public static class Mappers
|
|||||||
ProductPriceId = entity.ProductPriceId
|
ProductPriceId = entity.ProductPriceId
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Package ToModel(this CartPackages.Entities.Package entity) =>
|
public static Package ToModel(this Features.Shop.CartPackages.Entities.Package entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -44,7 +43,7 @@ public static class Mappers
|
|||||||
Summary = entity.Summary
|
Summary = entity.Summary
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ShoppingCartItem ToModel(this ShoppingCarts.Entities.ShoppingCartItem entity) =>
|
public static ShoppingCartItem ToModel(this Features.Shop.ShoppingCarts.Entities.ShoppingCartItem entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -55,7 +54,7 @@ public static class Mappers
|
|||||||
ShoppingCartId = entity.ShoppingCartId
|
ShoppingCartId = entity.ShoppingCartId
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ShoppingCart ToModel(this ShoppingCarts.Entities.ShoppingCart entity) =>
|
public static ShoppingCart ToModel(this Features.Shop.ShoppingCarts.Entities.ShoppingCart entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -65,7 +64,7 @@ public static class Mappers
|
|||||||
OrderId = entity.OrderId
|
OrderId = entity.OrderId
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Quote ToModel(this Quotes.Entities.Quote entity) =>
|
public static Quote ToModel(this Features.Shop.Quotes.Entities.Quote entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -80,7 +79,7 @@ public static class Mappers
|
|||||||
OrderId = entity.OrderId
|
OrderId = entity.OrderId
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Notification ToModel(this Notifications.Entities.Notification entity) =>
|
public static Notification ToModel(this Features.Shop.Notifications.Entities.Notification entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -104,7 +103,7 @@ public static class Mappers
|
|||||||
Errors = entity.Errors
|
Errors = entity.Errors
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Customer ToModel(this Customers.Entities.Customer entity) =>
|
public static Customer ToModel(this Features.Shop.Customers.Entities.Customer entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -129,7 +128,7 @@ public static class Mappers
|
|||||||
Whatsapp = entity.Whatsapp
|
Whatsapp = entity.Whatsapp
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Lead ToModel(this Leads.Entities.Lead entity) =>
|
public static Lead ToModel(this Features.Shop.Leads.Entities.Lead entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -150,7 +149,7 @@ public static class Mappers
|
|||||||
Status = entity.Status
|
Status = entity.Status
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Order ToModel(this Orders.Entities.Order entity) =>
|
public static Order ToModel(this Features.Shop.Orders.Entities.Order entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -164,7 +163,7 @@ public static class Mappers
|
|||||||
InvoiceUrl = entity.InvoiceUrl
|
InvoiceUrl = entity.InvoiceUrl
|
||||||
};
|
};
|
||||||
|
|
||||||
public static OrderRefund ToModel(this Orders.Entities.OrderRefund entity) =>
|
public static OrderRefund ToModel(this Features.Shop.Orders.Entities.OrderRefund entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -174,21 +173,19 @@ public static class Mappers
|
|||||||
Amount = entity.Amount
|
Amount = entity.Amount
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Products.Models.Product ToModel(this Products.Entities.Product entity) =>
|
public static Product ToModel(this Features.Shop.Products.Entities.Product entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
CreatedAt = entity.CreatedAt,
|
|
||||||
Name = entity.Name,
|
Name = entity.Name,
|
||||||
Description = entity.Description,
|
Description = entity.Description,
|
||||||
Active = entity.Active,
|
Active = entity.Active,
|
||||||
Summary = entity.Summary,
|
Summary = entity.Summary,
|
||||||
ImageUrl = entity.ImageUrl,
|
ImageUrl = entity.ImageUrl,
|
||||||
Thumbnails = entity.Thumbnails,
|
Thumbnails = entity.Thumbnails
|
||||||
Metadata = entity.Metadata,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Products.Models.ProductPrice ToModel(this Products.Entities.ProductPrice entity) =>
|
public static ProductPrice ToModel(this Features.Shop.Products.Entities.ProductPrice entity) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -2,12 +2,6 @@
|
|||||||
|
|
||||||
public static class Hash
|
public static class Hash
|
||||||
{
|
{
|
||||||
public static Func<string?, string?> StringToSha256Hash = (input) =>
|
public static Func<string?, string?> GenerateSha256HashString = (input) =>
|
||||||
Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(input!)));
|
Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(input!)));
|
||||||
|
|
||||||
public static Func<Stream, string?> StreamToSha256Hash = (stream) =>
|
|
||||||
Convert.ToHexString(SHA256.HashData(stream));
|
|
||||||
|
|
||||||
public static Func<byte[], string?> BytesToSha256Hash = (bytes) =>
|
|
||||||
Convert.ToHexString(SHA256.HashData(bytes));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using LiteCharms.Features.HealthChecks;
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.Extensions;
|
||||||
|
|
||||||
|
public static class HealthChecks
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddQuartzHealtchCheck(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddHealthChecks().AddCheck<QuartzHealthCheck>("Quartz");
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddPostgresHealtchCheck(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddHealthChecks().AddCheck<PostgresHealthCheck>("PostgreSQL");
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddHealthChecksSupport(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddHealthChecks()
|
||||||
|
.AddCheck("Self", () => HealthCheckResult.Healthy());
|
||||||
|
|
||||||
|
//services.AddHealthChecksUI(setup =>
|
||||||
|
//{
|
||||||
|
// setup.AddHealthCheckEndpoint("Lead Generator", $"{configuration["ASPNETCORE_URLS"]}/health");
|
||||||
|
// setup.SetEvaluationTimeInSeconds(15);
|
||||||
|
//}).AddInMemoryStorage(databaseName: "healthuidb");
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,14 @@
|
|||||||
namespace LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.Extensions;
|
||||||
|
|
||||||
public static class Postgres
|
public static class Postgres
|
||||||
{
|
{
|
||||||
public const string SchedulerDbConfigName = "PostgresScheduler";
|
public static IServiceCollection AddShopDatabase(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddPooledDbContextFactory<ShopDbContext>(options =>
|
||||||
|
options.UseNpgsql(configuration.GetConnectionString("PostgresShop")));
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
using LiteCharms.Features.Quartz;
|
using LiteCharms.Features.Quartz;
|
||||||
using LiteCharms.Features.Quartz.Abstractions;
|
using LiteCharms.Features.Quartz.Abstractions;
|
||||||
using static LiteCharms.Features.Extensions.Postgres;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.Extensions;
|
namespace LiteCharms.Features.Extensions;
|
||||||
|
|
||||||
public static class Quartz
|
public static class Quartz
|
||||||
{
|
{
|
||||||
public const string TechShopSchedulerName = "tech-shop";
|
private const string databaseConfigName = "PostgresScheduler";
|
||||||
public const string MidrandShopSchedulerName = "midrand-shop";
|
|
||||||
|
|
||||||
public static IServiceCollection AddQuartzSchedulerClient(this IServiceCollection services, string schedulerName, IConfiguration configuration)
|
public static IServiceCollection AddQuartzSchedulerClient(this IServiceCollection services, string schedulerName, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var connectionString = configuration.GetConnectionString(SchedulerDbConfigName);
|
var connectionString = configuration.GetConnectionString(databaseConfigName);
|
||||||
|
|
||||||
services.ConfigureCommon();
|
services.ConfigureCommon();
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ public static class Quartz
|
|||||||
storage.UseClustering(cluster =>
|
storage.UseClustering(cluster =>
|
||||||
{
|
{
|
||||||
cluster.CheckinInterval = TimeSpan.FromSeconds(30);
|
cluster.CheckinInterval = TimeSpan.FromSeconds(30);
|
||||||
cluster.CheckinMisfireThreshold = TimeSpan.FromSeconds(90);
|
cluster.CheckinMisfireThreshold = TimeSpan.FromSeconds(20);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -46,7 +44,7 @@ public static class Quartz
|
|||||||
|
|
||||||
public static IServiceCollection AddQuartzScheduler(this IServiceCollection services, string schedulerName, IConfiguration configuration)
|
public static IServiceCollection AddQuartzScheduler(this IServiceCollection services, string schedulerName, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var connectionString = configuration.GetConnectionString(SchedulerDbConfigName);
|
var connectionString = configuration.GetConnectionString(databaseConfigName);
|
||||||
|
|
||||||
services.ConfigureCommon();
|
services.ConfigureCommon();
|
||||||
|
|
||||||
@@ -64,8 +62,6 @@ public static class Quartz
|
|||||||
config.UseDefaultThreadPool(options => options.MaxConcurrency = 1);
|
config.UseDefaultThreadPool(options => options.MaxConcurrency = 1);
|
||||||
config.UseTimeZoneConverter();
|
config.UseTimeZoneConverter();
|
||||||
|
|
||||||
config.SetProperty("quartz.jobStore.misfireThreshold", TimeSpan.FromMinutes(2).TotalMilliseconds.ToString());
|
|
||||||
|
|
||||||
config.UsePersistentStore(storage =>
|
config.UsePersistentStore(storage =>
|
||||||
{
|
{
|
||||||
storage.PerformSchemaValidation = false;
|
storage.PerformSchemaValidation = false;
|
||||||
@@ -78,7 +74,7 @@ public static class Quartz
|
|||||||
storage.UseClustering(cluster =>
|
storage.UseClustering(cluster =>
|
||||||
{
|
{
|
||||||
cluster.CheckinInterval = TimeSpan.FromSeconds(30);
|
cluster.CheckinInterval = TimeSpan.FromSeconds(30);
|
||||||
cluster.CheckinMisfireThreshold = TimeSpan.FromSeconds(90);
|
cluster.CheckinMisfireThreshold = TimeSpan.FromSeconds(20);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
using LiteCharms.Features.S3;
|
|
||||||
using LiteCharms.Features.S3.Abstractions;
|
|
||||||
using static LiteCharms.Features.S3.Constants;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.Extensions;
|
|
||||||
|
|
||||||
public static class S3
|
|
||||||
{
|
|
||||||
public static IServiceCollection AddGarageS3(this IServiceCollection services, IConfiguration configuration)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(configuration.GetSection($"{BookshopS3SettingsSection}:ServiceUrl").Value))
|
|
||||||
{
|
|
||||||
services.AddKeyedSingleton<IAmazonS3, AmazonS3Client>(BookshopBucketName, (provider, client) =>
|
|
||||||
new AmazonS3Client(new BasicAWSCredentials(configuration.GetSection($"{BookshopS3SettingsSection}:AccessKey").Value,
|
|
||||||
configuration.GetSection($"{BookshopS3SettingsSection}:SecretKey").Value),
|
|
||||||
new AmazonS3Config
|
|
||||||
{
|
|
||||||
ServiceURL = configuration.GetSection($"{BookshopS3SettingsSection}:ServiceUrl").Value,
|
|
||||||
AuthenticationRegion = configuration.GetSection($"{BookshopS3SettingsSection}:Region").Value,
|
|
||||||
ForcePathStyle = true,
|
|
||||||
EndpointDiscoveryEnabled = true,
|
|
||||||
UseHttp = configuration.GetSection($"{BookshopS3SettingsSection}:ServiceUrl").Value!.Contains("http://")
|
|
||||||
}));
|
|
||||||
|
|
||||||
services.AddKeyedScoped<IS3Service, BookshopS3Service>(BookshopBucketName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(configuration.GetSection($"{BookshopInvoicesS3SettingsSection}:ServiceUrl").Value))
|
|
||||||
{
|
|
||||||
services.AddKeyedSingleton<IAmazonS3, AmazonS3Client>(BookshopInvoicesBucketName, (provider, client) =>
|
|
||||||
new AmazonS3Client(new BasicAWSCredentials(configuration.GetSection($"{BookshopInvoicesS3SettingsSection}:AccessKey").Value,
|
|
||||||
configuration.GetSection($"{BookshopInvoicesS3SettingsSection}:SecretKey").Value),
|
|
||||||
new AmazonS3Config
|
|
||||||
{
|
|
||||||
ServiceURL = configuration.GetSection($"{BookshopInvoicesS3SettingsSection}:ServiceUrl").Value,
|
|
||||||
AuthenticationRegion = configuration.GetSection($"{BookshopInvoicesS3SettingsSection}:Region").Value,
|
|
||||||
ForcePathStyle = true,
|
|
||||||
EndpointDiscoveryEnabled = true,
|
|
||||||
UseHttp = configuration.GetSection($"{BookshopS3SettingsSection}:ServiceUrl").Value!.Contains("http://")
|
|
||||||
}));
|
|
||||||
|
|
||||||
services.AddKeyedScoped<IS3Service, BookshopInvoicesS3Service>(BookshopInvoicesBucketName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(configuration.GetSection($"{BookshopQuotesS3SettingsSection}:ServiceUrl").Value))
|
|
||||||
{
|
|
||||||
services.AddKeyedSingleton<IAmazonS3, AmazonS3Client>(BookshopQuotesBucketName, (provider, client) =>
|
|
||||||
new AmazonS3Client(new BasicAWSCredentials(configuration.GetSection($"{BookshopQuotesS3SettingsSection}:AccessKey").Value,
|
|
||||||
configuration.GetSection($"{BookshopQuotesS3SettingsSection}:SecretKey").Value),
|
|
||||||
new AmazonS3Config
|
|
||||||
{
|
|
||||||
ServiceURL = configuration.GetSection($"{BookshopQuotesS3SettingsSection}:ServiceUrl").Value,
|
|
||||||
AuthenticationRegion = configuration.GetSection($"{BookshopQuotesS3SettingsSection}:Region").Value,
|
|
||||||
ForcePathStyle = true,
|
|
||||||
EndpointDiscoveryEnabled = true,
|
|
||||||
UseHttp = configuration.GetSection($"{BookshopS3SettingsSection}:ServiceUrl").Value!.Contains("http://")
|
|
||||||
}));
|
|
||||||
|
|
||||||
services.AddKeyedScoped<IS3Service, BookshopQuotesS3Service>(BookshopQuotesBucketName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using LiteCharms.Features.Shop.CartPackages;
|
||||||
|
using LiteCharms.Features.Shop.Customers;
|
||||||
|
using LiteCharms.Features.Shop.Leads;
|
||||||
|
using LiteCharms.Features.Shop.Notifications;
|
||||||
|
using LiteCharms.Features.Shop.Orders;
|
||||||
|
using LiteCharms.Features.Shop.Products;
|
||||||
|
using LiteCharms.Features.Shop.Quotes;
|
||||||
|
using LiteCharms.Features.Shop.ShoppingCarts;
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.Extensions;
|
||||||
|
|
||||||
|
public static class Shop
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddShopServices(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSingleton<PackageService>()
|
||||||
|
.AddSingleton<LeadService>()
|
||||||
|
.AddSingleton<NotificationService>()
|
||||||
|
.AddSingleton<OrderService>()
|
||||||
|
.AddSingleton<ProductService>()
|
||||||
|
.AddSingleton<QuoteService>()
|
||||||
|
.AddSingleton<ShoppingCartService>()
|
||||||
|
.AddSingleton<CustomerService>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
-7
@@ -1,10 +1,8 @@
|
|||||||
using static LiteCharms.Features.TechShop.Extensions.Postgres;
|
namespace LiteCharms.Features.HealthChecks;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.HealthChecks;
|
public class PostgresHealthCheck(IConfiguration configuration) : IHealthCheck
|
||||||
|
|
||||||
public class PostgresShopHealthCheck(IConfiguration configuration) : IHealthCheck
|
|
||||||
{
|
{
|
||||||
private readonly string connectionString = configuration.GetConnectionString(TechShopDbConfigName)!;
|
private readonly string connectionString = configuration.GetConnectionString("PostgresShop")!;
|
||||||
|
|
||||||
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
|
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
@@ -18,11 +16,11 @@ public class PostgresShopHealthCheck(IConfiguration configuration) : IHealthChec
|
|||||||
|
|
||||||
await command.ExecuteScalarAsync(cancellationToken);
|
await command.ExecuteScalarAsync(cancellationToken);
|
||||||
|
|
||||||
return HealthCheckResult.Healthy($"{TechShopDbConfigName} is responsive.");
|
return HealthCheckResult.Healthy("PostgreSQL is responsive.");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return HealthCheckResult.Unhealthy($"{TechShopDbConfigName} is unreachable.", ex);
|
return HealthCheckResult.Unhealthy("PostgreSQL is unreachable.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
namespace LiteCharms.Features.HealthChecks;
|
||||||
|
|
||||||
|
public class QuartzHealthCheck(ISchedulerFactory schedulerFactory) : IHealthCheck
|
||||||
|
{
|
||||||
|
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var scheduler = await schedulerFactory.GetScheduler(cancellationToken);
|
||||||
|
|
||||||
|
if (!scheduler.IsStarted)
|
||||||
|
return HealthCheckResult.Unhealthy("Quartz scheduler is not running");
|
||||||
|
|
||||||
|
await scheduler.CheckExists(new JobKey(Guid.NewGuid().ToString()), cancellationToken);
|
||||||
|
|
||||||
|
return HealthCheckResult.Healthy("Quartz scheduler is ready");
|
||||||
|
}
|
||||||
|
catch (SchedulerException)
|
||||||
|
{
|
||||||
|
return HealthCheckResult.Unhealthy("Quartz scheduler cannot connect to the store");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -129,17 +129,6 @@
|
|||||||
<Using Include="Mediator" />
|
<Using Include="Mediator" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Amazon S3 SDK -->
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.1" />
|
|
||||||
<PackageReference Include="AWSSDK.S3" Version="4.0.23.4" />
|
|
||||||
|
|
||||||
<!-- global Usings -->
|
|
||||||
<Using Include="Amazon.S3" />
|
|
||||||
<Using Include="Amazon.S3.Model" />
|
|
||||||
<Using Include="Amazon.Runtime" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Shared Usings -->
|
<!-- Shared Usings -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Using Include="Microsoft.AspNetCore.Builder" />
|
<Using Include="Microsoft.AspNetCore.Builder" />
|
||||||
@@ -160,5 +149,8 @@
|
|||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Shop\Postgres\Migrations\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ public class JobOrchestrator(ISchedulerFactory schedulerFactory) : IJobOrchestra
|
|||||||
|
|
||||||
var trigger = global::Quartz.TriggerBuilder.Create()
|
var trigger = global::Quartz.TriggerBuilder.Create()
|
||||||
.WithIdentity(triggerKey)
|
.WithIdentity(triggerKey)
|
||||||
.WithDescription($"Scheduled via Main Job at {now:g}")
|
.WithDescription($"Scheduled via Main Job at {now:g} UTC")
|
||||||
.WithCronSchedule(cronExpression, cron => cron
|
.WithCronSchedule(cronExpression, cron => cron
|
||||||
.WithMisfireHandlingInstructionIgnoreMisfires())
|
.WithMisfireHandlingInstructionFireAndProceed())
|
||||||
.StartAt(now)
|
.StartAt(now)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|||||||
@@ -10,28 +10,16 @@ public class MediatorJob<TNotification>(IMediator mediator) : IJob where TNotifi
|
|||||||
{
|
{
|
||||||
var data = context.MergedJobDataMap["Payload"] as string;
|
var data = context.MergedJobDataMap["Payload"] as string;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(data))
|
if (string.IsNullOrWhiteSpace(data)) return;
|
||||||
{
|
|
||||||
Trace.WriteLine("Job Payload missing, job ended");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var notification = JsonSerializer.Deserialize<TNotification>(data);
|
var notification = JsonSerializer.Deserialize<TNotification>(data);
|
||||||
|
|
||||||
if (notification is null)
|
if (notification is null) return;
|
||||||
{
|
|
||||||
Trace.WriteLine("Notification could not be JSon converted from data string, job ended");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var activity = MediatorTelemetry.Source.StartActivity($"Quartz: {typeof(TNotification).Name}");
|
using var activity = MediatorTelemetry.Source.StartActivity($"Quartz: {typeof(TNotification).Name}");
|
||||||
|
|
||||||
activity?.SetTag("event.correlation_id", notification.CorrelationId);
|
activity?.SetTag("event.correlation_id", notification.CorrelationId);
|
||||||
|
|
||||||
await mediator.Publish(notification, context.CancellationToken);
|
await mediator.Publish(notification, context.CancellationToken);
|
||||||
|
|
||||||
Trace.WriteLine("Job published");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace LiteCharms.Features.S3.Abstractions;
|
|
||||||
|
|
||||||
public interface IS3Service
|
|
||||||
{
|
|
||||||
Task<Result<string>> UploadFileAsync(string fileName, Stream fileStream, string contentType, CancellationToken cancellationToken = default);
|
|
||||||
Task<Result> DeleteFileAsync(string fileKey, CancellationToken cancellationToken = default);
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
using static LiteCharms.Features.Extensions.Hash;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.S3.Abstractions;
|
|
||||||
|
|
||||||
public abstract class S3ServiceBase(IAmazonS3 amazonS3)
|
|
||||||
{
|
|
||||||
protected readonly IAmazonS3 Client = amazonS3;
|
|
||||||
|
|
||||||
protected abstract string BucketName { get; }
|
|
||||||
protected abstract string CdnBaseUrl { get; }
|
|
||||||
|
|
||||||
public virtual async Task<Result<string>> UploadFileAsync(string fileName, Stream fileStream, string contentType, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(BucketName))
|
|
||||||
return Result.Fail<string>("Bucket name is not configured.");
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(CdnBaseUrl))
|
|
||||||
return Result.Fail<string>("CDN base URL is not configured.");
|
|
||||||
|
|
||||||
using var stream = new MemoryStream();
|
|
||||||
|
|
||||||
await fileStream.CopyToAsync(stream, cancellationToken);
|
|
||||||
await fileStream.DisposeAsync();
|
|
||||||
|
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
var fileHash = StreamToSha256Hash(stream);
|
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(fileHash))
|
|
||||||
return Result.Fail<string>("Failed to compute file hash.");
|
|
||||||
|
|
||||||
var fileKey = $"{fileHash.ToLower()}{Path.GetExtension(fileName)}";
|
|
||||||
|
|
||||||
var putRequest = new PutObjectRequest
|
|
||||||
{
|
|
||||||
BucketName = BucketName,
|
|
||||||
Key = fileKey,
|
|
||||||
InputStream = stream,
|
|
||||||
ContentType = contentType,
|
|
||||||
UseChunkEncoding = false
|
|
||||||
};
|
|
||||||
|
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
var response = await Client.PutObjectAsync(putRequest, cancellationToken);
|
|
||||||
|
|
||||||
return response.HttpStatusCode != System.Net.HttpStatusCode.OK
|
|
||||||
? Result.Fail<string>($"Failed to upload {fileName} to S3.")
|
|
||||||
: Result.Ok($"{CdnBaseUrl}/{fileKey}");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return Result.Fail<string>(new Error($"Error uploading {fileName} to S3: {ex.Message}").CausedBy(ex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual async Task<Result> DeleteFileAsync(string fileKey, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(BucketName))
|
|
||||||
return Result.Fail("Bucket name is not configured.");
|
|
||||||
|
|
||||||
var deleteRequest = new DeleteObjectRequest
|
|
||||||
{
|
|
||||||
BucketName = BucketName,
|
|
||||||
Key = fileKey
|
|
||||||
};
|
|
||||||
|
|
||||||
var response = await Client.DeleteObjectAsync(deleteRequest, cancellationToken);
|
|
||||||
|
|
||||||
return response.HttpStatusCode != System.Net.HttpStatusCode.NoContent
|
|
||||||
? Result.Fail($"Failed to delete {fileKey} from S3.")
|
|
||||||
: Result.Ok();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return Result.Fail(new Error($"Error deleting {fileKey} from S3: {ex.Message}").CausedBy(ex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using LiteCharms.Features.S3.Abstractions;
|
|
||||||
using static LiteCharms.Features.S3.Constants;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.S3;
|
|
||||||
|
|
||||||
public class BookshopInvoicesS3Service(IConfiguration configuration, [FromKeyedServices(BookshopInvoicesBucketName)] IAmazonS3 amazonS3) :
|
|
||||||
S3ServiceBase(amazonS3), IS3Service
|
|
||||||
{
|
|
||||||
protected override string BucketName => configuration.GetSection($"{BookshopInvoicesS3SettingsSection}:BucketName").Value ?? "";
|
|
||||||
protected override string CdnBaseUrl => configuration.GetSection($"{BookshopInvoicesS3SettingsSection}:CdnBaseUrl").Value ?? "";
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using LiteCharms.Features.S3.Abstractions;
|
|
||||||
using static LiteCharms.Features.S3.Constants;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.S3;
|
|
||||||
|
|
||||||
public class BookshopQuotesS3Service(IConfiguration configuration, [FromKeyedServices(BookshopQuotesBucketName)] IAmazonS3 amazonS3) :
|
|
||||||
S3ServiceBase(amazonS3), IS3Service
|
|
||||||
{
|
|
||||||
protected override string BucketName => configuration.GetSection($"{BookshopQuotesS3SettingsSection}:BucketName").Value ?? "";
|
|
||||||
protected override string CdnBaseUrl => configuration.GetSection($"{BookshopQuotesS3SettingsSection}:CdnBaseUrl").Value ?? "";
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using LiteCharms.Features.S3.Abstractions;
|
|
||||||
using static LiteCharms.Features.S3.Constants;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.S3;
|
|
||||||
|
|
||||||
public class BookshopS3Service(IConfiguration configuration, [FromKeyedServices(BookshopBucketName)] IAmazonS3 amazonS3) :
|
|
||||||
S3ServiceBase(amazonS3), IS3Service
|
|
||||||
{
|
|
||||||
protected override string BucketName => configuration.GetSection($"{BookshopS3SettingsSection}:BucketName").Value ?? "";
|
|
||||||
protected override string CdnBaseUrl => configuration.GetSection($"{BookshopS3SettingsSection}:CdnBaseUrl").Value ?? "";
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
namespace LiteCharms.Features.S3.Configuration;
|
|
||||||
|
|
||||||
public class S3Settings
|
|
||||||
{
|
|
||||||
public string? ServiceUrl { get; set; }
|
|
||||||
|
|
||||||
public string? AccessKey { get; set; }
|
|
||||||
|
|
||||||
public string? SecretKey { get; set; }
|
|
||||||
|
|
||||||
public string? BucketName { get; set; }
|
|
||||||
|
|
||||||
public string? Region { get; set; }
|
|
||||||
|
|
||||||
public string? CdnBaseUrl { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
namespace LiteCharms.Features.S3;
|
|
||||||
|
|
||||||
public static class Constants
|
|
||||||
{
|
|
||||||
public const string BookshopS3SettingsSection = "BookshopS3Settings";
|
|
||||||
public const string BookshopInvoicesS3SettingsSection = "BookshopInvoicesS3Settings";
|
|
||||||
public const string BookshopQuotesS3SettingsSection = "BookshopQuotesS3Settings";
|
|
||||||
|
|
||||||
public const string BookshopBucketName = "bookshop";
|
|
||||||
public const string BookshopInvoicesBucketName = "bookshop.invoices";
|
|
||||||
public const string BookshopQuotesBucketName = "bookshop.quotes";
|
|
||||||
}
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.CartPackages.Entities;
|
namespace LiteCharms.Features.Shop.CartPackages.Entities;
|
||||||
|
|
||||||
[EntityTypeConfiguration<PackageConfirguration, Package>]
|
[EntityTypeConfiguration<PackageConfirguration, Package>]
|
||||||
public class Package : Models.Package
|
public class Package : Models.Package
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.CartPackages.Entities;
|
namespace LiteCharms.Features.Shop.CartPackages.Entities;
|
||||||
|
|
||||||
public class PackageConfirguration : IEntityTypeConfiguration<Package>
|
public class PackageConfirguration : IEntityTypeConfiguration<Package>
|
||||||
{
|
{
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
using LiteCharms.Features.TechShop.Products.Entities;
|
using LiteCharms.Features.Shop.Products.Entities;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.CartPackages.Entities;
|
namespace LiteCharms.Features.Shop.CartPackages.Entities;
|
||||||
|
|
||||||
[EntityTypeConfiguration<PackageItemConfiguration, PackageItem>]
|
[EntityTypeConfiguration<PackageItemConfiguration, PackageItem>]
|
||||||
public class PackageItem : Models.PackageItem
|
public class PackageItem : Models.PackageItem
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.CartPackages.Entities;
|
namespace LiteCharms.Features.Shop.CartPackages.Entities;
|
||||||
|
|
||||||
public class PackageItemConfiguration : IEntityTypeConfiguration<PackageItem>
|
public class PackageItemConfiguration : IEntityTypeConfiguration<PackageItem>
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.CartPackages.Models;
|
namespace LiteCharms.Features.Shop.CartPackages.Models;
|
||||||
|
|
||||||
public class Package
|
public class Package
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.CartPackages.Models;
|
namespace LiteCharms.Features.Shop.CartPackages.Models;
|
||||||
|
|
||||||
public class PackageItem
|
public class PackageItem
|
||||||
{
|
{
|
||||||
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Extensions;
|
||||||
using LiteCharms.Features.Models;
|
using LiteCharms.Features.Models;
|
||||||
using LiteCharms.Features.TechShop.CartPackages.Models;
|
using LiteCharms.Features.Shop.CartPackages.Models;
|
||||||
using LiteCharms.Features.TechShop.Extensions;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
using static LiteCharms.Features.Extensions.Timezones;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.CartPackages;
|
namespace LiteCharms.Features.Shop.CartPackages;
|
||||||
|
|
||||||
public class PackageService(IDbContextFactory<ShopDbContext> contextFactory)
|
public class PackageService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||||
{
|
{
|
||||||
+3
-4
@@ -1,10 +1,9 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Extensions;
|
||||||
using LiteCharms.Features.Models;
|
using LiteCharms.Features.Models;
|
||||||
using LiteCharms.Features.TechShop.Customers.Models;
|
using LiteCharms.Features.Shop.Customers.Models;
|
||||||
using LiteCharms.Features.TechShop.Extensions;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Customers;
|
namespace LiteCharms.Features.Shop.Customers;
|
||||||
|
|
||||||
public class CustomerService(IDbContextFactory<ShopDbContext> contextFactory)
|
public class CustomerService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||||
{
|
{
|
||||||
+5
-5
@@ -1,9 +1,9 @@
|
|||||||
using LiteCharms.Features.TechShop.Leads.Entities;
|
using LiteCharms.Features.Shop.Leads.Entities;
|
||||||
using LiteCharms.Features.TechShop.Orders.Entities;
|
using LiteCharms.Features.Shop.Orders.Entities;
|
||||||
using LiteCharms.Features.TechShop.Quotes.Entities;
|
using LiteCharms.Features.Shop.Quotes.Entities;
|
||||||
using LiteCharms.Features.TechShop.ShoppingCarts.Entities;
|
using LiteCharms.Features.Shop.ShoppingCarts.Entities;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Customers.Entities;
|
namespace LiteCharms.Features.Shop.Customers.Entities;
|
||||||
|
|
||||||
[EntityTypeConfiguration<CustomerConfiguration, Customer>]
|
[EntityTypeConfiguration<CustomerConfiguration, Customer>]
|
||||||
public class Customer : Models.Customer
|
public class Customer : Models.Customer
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Customers.Entities;
|
namespace LiteCharms.Features.Shop.Customers.Entities;
|
||||||
|
|
||||||
public class CustomerConfiguration : IEntityTypeConfiguration<Customer>
|
public class CustomerConfiguration : IEntityTypeConfiguration<Customer>
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Customers.Models;
|
namespace LiteCharms.Features.Shop.Customers.Models;
|
||||||
|
|
||||||
public class Customer
|
public class Customer
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Customers.Models;
|
namespace LiteCharms.Features.Shop.Customers.Models;
|
||||||
|
|
||||||
public record CreateCustomer
|
public record CreateCustomer
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,16 @@
|
|||||||
namespace LiteCharms.Features.TechShop;
|
namespace LiteCharms.Features.Shop;
|
||||||
|
|
||||||
|
public enum EmailStatuses : int
|
||||||
|
{
|
||||||
|
GeneralError = 0,
|
||||||
|
AuthenticationError = 1,
|
||||||
|
ProtocolError = 2,
|
||||||
|
Connected = 3,
|
||||||
|
Disconnected = 4,
|
||||||
|
TooManyConnections = 5,
|
||||||
|
ConnectionAborted = 6,
|
||||||
|
Success = 7
|
||||||
|
}
|
||||||
|
|
||||||
public enum CorrelationIdTypes : int
|
public enum CorrelationIdTypes : int
|
||||||
{
|
{
|
||||||
@@ -15,6 +27,13 @@ public enum CorrelationIdTypes : int
|
|||||||
LinkedIn = 10
|
LinkedIn = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Priorities : int
|
||||||
|
{
|
||||||
|
Low = 0,
|
||||||
|
Medium = 1,
|
||||||
|
High = 2,
|
||||||
|
}
|
||||||
|
|
||||||
public enum NotificationPlatforms : int
|
public enum NotificationPlatforms : int
|
||||||
{
|
{
|
||||||
Email = 1,
|
Email = 1,
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
using LiteCharms.Features.TechShop.Customers.Entities;
|
using LiteCharms.Features.Shop.Customers.Entities;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Leads.Entities;
|
namespace LiteCharms.Features.Shop.Leads.Entities;
|
||||||
|
|
||||||
[EntityTypeConfiguration<LeadConfiguration, Lead>]
|
[EntityTypeConfiguration<LeadConfiguration, Lead>]
|
||||||
public class Lead : Models.Lead
|
public class Lead : Models.Lead
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Leads.Entities;
|
namespace LiteCharms.Features.Shop.Leads.Entities;
|
||||||
|
|
||||||
public class LeadConfiguration : IEntityTypeConfiguration<Lead>
|
public class LeadConfiguration : IEntityTypeConfiguration<Lead>
|
||||||
{
|
{
|
||||||
+4
-5
@@ -1,11 +1,10 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Extensions;
|
||||||
using LiteCharms.Features.Models;
|
using LiteCharms.Features.Models;
|
||||||
using LiteCharms.Features.TechShop.Extensions;
|
using LiteCharms.Features.Shop.Leads.Models;
|
||||||
using LiteCharms.Features.TechShop.Leads.Models;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
|
||||||
using static LiteCharms.Features.Extensions.Hash;
|
using static LiteCharms.Features.Extensions.Hash;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Leads;
|
namespace LiteCharms.Features.Shop.Leads;
|
||||||
|
|
||||||
public class LeadService(IDbContextFactory<ShopDbContext> contextFactory)
|
public class LeadService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||||
{
|
{
|
||||||
@@ -29,7 +28,7 @@ public class LeadService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
FeedItemId = request.FeedItemId,
|
FeedItemId = request.FeedItemId,
|
||||||
Status = LeadStatus.New,
|
Status = LeadStatus.New,
|
||||||
TargetId = request.TargetId,
|
TargetId = request.TargetId,
|
||||||
AttributionHash = StringToSha256Hash.Invoke($"{request.ClickId}{request.AppClickId}{request.WebClickId}")
|
AttributionHash = GenerateSha256HashString.Invoke($"{request.ClickId}{request.AppClickId}{request.WebClickId}")
|
||||||
});
|
});
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Leads.Models;
|
namespace LiteCharms.Features.Shop.Leads.Models;
|
||||||
|
|
||||||
public class Lead
|
public class Lead
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Leads.Models;
|
namespace LiteCharms.Features.Shop.Leads.Models;
|
||||||
|
|
||||||
public record CreateLead
|
public record CreateLead
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Notifications.Entities;
|
namespace LiteCharms.Features.Shop.Notifications.Entities;
|
||||||
|
|
||||||
[EntityTypeConfiguration<NotificationConfiguration, Notification>]
|
[EntityTypeConfiguration<NotificationConfiguration, Notification>]
|
||||||
public class Notification : Models.Notification;
|
public class Notification : Models.Notification;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Notifications.Entities;
|
namespace LiteCharms.Features.Shop.Notifications.Entities;
|
||||||
|
|
||||||
public class NotificationConfiguration : IEntityTypeConfiguration<Notification>
|
public class NotificationConfiguration : IEntityTypeConfiguration<Notification>
|
||||||
{
|
{
|
||||||
+6
-13
@@ -1,8 +1,8 @@
|
|||||||
using LiteCharms.Features.Email;
|
using LiteCharms.Features.Email;
|
||||||
using LiteCharms.Features.TechShop.Notifications.Models;
|
using LiteCharms.Features.Shop.Notifications.Models;
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Notifications.Events.Handlers;
|
namespace LiteCharms.Features.Shop.Notifications.Events.Handlers;
|
||||||
|
|
||||||
public class ProcessEmailNotificationsEventHandler(IDbContextFactory<ShopDbContext> contextFactory, ILogger<ProcessEmailNotificationsEvent> logger,
|
public class ProcessEmailNotificationsEventHandler(IDbContextFactory<ShopDbContext> contextFactory, ILogger<ProcessEmailNotificationsEvent> logger,
|
||||||
EmailService emailService) : INotificationHandler<ProcessEmailNotificationsEvent>
|
EmailService emailService) : INotificationHandler<ProcessEmailNotificationsEvent>
|
||||||
@@ -15,20 +15,17 @@ public class ProcessEmailNotificationsEventHandler(IDbContextFactory<ShopDbConte
|
|||||||
{
|
{
|
||||||
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
if (emailService.Status != EmailStatuses.Connected)
|
|
||||||
await emailService.ConnectAsync(cancellationToken);
|
|
||||||
|
|
||||||
var notifications = await context.Notifications
|
var notifications = await context.Notifications
|
||||||
.OrderByDescending(o => o.CreatedAt)
|
.OrderByDescending(o => o.CreatedAt)
|
||||||
.ThenBy(o => o.Priority)
|
.ThenBy(o => o.Priority)
|
||||||
.Where(n => n.Platform == NotificationPlatforms.Email &&
|
.Where(n => n.CorrelationIdType == CorrelationIdTypes.Email)
|
||||||
n.Direction == NotificationDirection.Outgoing && n.Processed == false)
|
.Where(n => n.Direction == NotificationDirection.Outgoing)
|
||||||
.Take(message.MaxRecords)
|
.Take(message.MaxRecords)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
foreach (var notification in notifications)
|
foreach (var notification in notifications)
|
||||||
{
|
{
|
||||||
if (dropBatch) break;
|
if (dropBatch || cancellationToken.IsCancellationRequested) break;
|
||||||
|
|
||||||
var sendResult = await SendEmailAsync(notification,emailService, cancellationToken);
|
var sendResult = await SendEmailAsync(notification,emailService, cancellationToken);
|
||||||
|
|
||||||
@@ -55,10 +52,6 @@ public class ProcessEmailNotificationsEventHandler(IDbContextFactory<ShopDbConte
|
|||||||
{
|
{
|
||||||
logger.LogError(ex, ex.Message);
|
logger.LogError(ex, ex.Message);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
await emailService.DisconnectAsync(cancellationToken);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendEmailAsync(Notification notification, EmailService service, CancellationToken cancellationToken = default)
|
private async Task<Result> SendEmailAsync(Notification notification, EmailService service, CancellationToken cancellationToken = default)
|
||||||
+1
-3
@@ -1,6 +1,6 @@
|
|||||||
using LiteCharms.Features.Abstractions;
|
using LiteCharms.Features.Abstractions;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Notifications.Events;
|
namespace LiteCharms.Features.Shop.Notifications.Events;
|
||||||
|
|
||||||
public class ProcessEmailNotificationsEvent : EventBase, IEvent
|
public class ProcessEmailNotificationsEvent : EventBase, IEvent
|
||||||
{
|
{
|
||||||
@@ -8,8 +8,6 @@ public class ProcessEmailNotificationsEvent : EventBase, IEvent
|
|||||||
|
|
||||||
public int MaxRecords { get; set; }
|
public int MaxRecords { get; set; }
|
||||||
|
|
||||||
public ProcessEmailNotificationsEvent() { MaxRecords = 1000; }
|
|
||||||
|
|
||||||
private ProcessEmailNotificationsEvent(int maxRecords = 1000) => MaxRecords = maxRecords;
|
private ProcessEmailNotificationsEvent(int maxRecords = 1000) => MaxRecords = maxRecords;
|
||||||
|
|
||||||
public static ProcessEmailNotificationsEvent Create(int maxRecords = 1000) => new(maxRecords);
|
public static ProcessEmailNotificationsEvent Create(int maxRecords = 1000) => new(maxRecords);
|
||||||
+1
-3
@@ -1,6 +1,4 @@
|
|||||||
using LiteCharms.Features.TechShop;
|
namespace LiteCharms.Features.Shop.Notifications.Models;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Notifications.Models;
|
|
||||||
|
|
||||||
public class Notification
|
public class Notification
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Notifications.Models;
|
namespace LiteCharms.Features.Shop.Notifications.Models;
|
||||||
|
|
||||||
public record CreateNotification
|
public record CreateNotification
|
||||||
{
|
{
|
||||||
+11
-9
@@ -1,10 +1,9 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Extensions;
|
||||||
using LiteCharms.Features.Models;
|
using LiteCharms.Features.Models;
|
||||||
using LiteCharms.Features.TechShop.Extensions;
|
using LiteCharms.Features.Shop.Notifications.Models;
|
||||||
using LiteCharms.Features.TechShop.Notifications.Models;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Notifications;
|
namespace LiteCharms.Features.Shop.Notifications;
|
||||||
|
|
||||||
public class NotificationService(IDbContextFactory<ShopDbContext> contextFactory)
|
public class NotificationService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||||
{
|
{
|
||||||
@@ -64,8 +63,8 @@ public class NotificationService(IDbContextFactory<ShopDbContext> contextFactory
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fromDate = range.From.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc);
|
var fromDate = range.From.ToDateTime(TimeOnly.MinValue);
|
||||||
var toDate = range.To.ToDateTime(TimeOnly.MaxValue, DateTimeKind.Utc);
|
var toDate = range.To.ToDateTime(TimeOnly.MaxValue);
|
||||||
|
|
||||||
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
@@ -97,9 +96,12 @@ public class NotificationService(IDbContextFactory<ShopDbContext> contextFactory
|
|||||||
return Result.Fail(new Error($"Notification with id {request.NotificationId} not found."));
|
return Result.Fail(new Error($"Notification with id {request.NotificationId} not found."));
|
||||||
|
|
||||||
notification.Processed = request.Processed;
|
notification.Processed = request.Processed;
|
||||||
notification.UpdatedAt = DateTime.UtcNow;
|
|
||||||
notification.HasError = request.HasError;
|
if (request.HasError)
|
||||||
notification.Errors = request.Errors;
|
{
|
||||||
|
notification.HasError = request.HasError;
|
||||||
|
notification.Errors = request.Errors;
|
||||||
|
}
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
? Result.Ok()
|
? Result.Ok()
|
||||||
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
using LiteCharms.Features.TechShop.Customers.Entities;
|
using LiteCharms.Features.Shop.Customers.Entities;
|
||||||
using LiteCharms.Features.TechShop.Quotes.Entities;
|
using LiteCharms.Features.Shop.Quotes.Entities;
|
||||||
using LiteCharms.Features.TechShop.ShoppingCarts.Entities;
|
using LiteCharms.Features.Shop.ShoppingCarts.Entities;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Orders.Entities;
|
namespace LiteCharms.Features.Shop.Orders.Entities;
|
||||||
|
|
||||||
[EntityTypeConfiguration<OrderConfiguration, Order>]
|
[EntityTypeConfiguration<OrderConfiguration, Order>]
|
||||||
public class Order : Models.Order
|
public class Order : Models.Order
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Orders.Entities;
|
namespace LiteCharms.Features.Shop.Orders.Entities;
|
||||||
|
|
||||||
public class OrderConfiguration : IEntityTypeConfiguration<Order>
|
public class OrderConfiguration : IEntityTypeConfiguration<Order>
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Orders.Entities;
|
namespace LiteCharms.Features.Shop.Orders.Entities;
|
||||||
|
|
||||||
[EntityTypeConfiguration<OrderRefundConfiguration, OrderRefund>]
|
[EntityTypeConfiguration<OrderRefundConfiguration, OrderRefund>]
|
||||||
public class OrderRefund : Models.OrderRefund
|
public class OrderRefund : Models.OrderRefund
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Orders.Entities;
|
namespace LiteCharms.Features.Shop.Orders.Entities;
|
||||||
|
|
||||||
public class OrderRefundConfiguration : IEntityTypeConfiguration<OrderRefund>
|
public class OrderRefundConfiguration : IEntityTypeConfiguration<OrderRefund>
|
||||||
{
|
{
|
||||||
+1
-3
@@ -1,6 +1,4 @@
|
|||||||
using LiteCharms.Features.TechShop;
|
namespace LiteCharms.Features.Shop.Orders.Models;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Orders.Models;
|
|
||||||
|
|
||||||
public class Order
|
public class Order
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace LiteCharms.Features.TechShop.Orders.Models;
|
namespace LiteCharms.Features.Shop.Orders.Models;
|
||||||
|
|
||||||
public class OrderRefund
|
public class OrderRefund
|
||||||
{
|
{
|
||||||
+1
-3
@@ -1,6 +1,4 @@
|
|||||||
using LiteCharms.Features.TechShop;
|
namespace LiteCharms.Features.Shop.Orders.Models;
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Orders.Models;
|
|
||||||
|
|
||||||
public record CreateOrder
|
public record CreateOrder
|
||||||
{
|
{
|
||||||
+3
-4
@@ -1,10 +1,9 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Extensions;
|
||||||
using LiteCharms.Features.Models;
|
using LiteCharms.Features.Models;
|
||||||
using LiteCharms.Features.TechShop.Extensions;
|
using LiteCharms.Features.Shop.Orders.Models;
|
||||||
using LiteCharms.Features.TechShop.Orders.Models;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Orders;
|
namespace LiteCharms.Features.Shop.Orders;
|
||||||
|
|
||||||
public class OrderService(IDbContextFactory<ShopDbContext> contextFactory)
|
public class OrderService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||||
{
|
{
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
@@ -9,7 +9,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
namespace LiteCharms.Features.Shop.Postgres.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ShopDbContext))]
|
[DbContext(typeof(ShopDbContext))]
|
||||||
[Migration("20260512065421_Init")]
|
[Migration("20260512065421_Init")]
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
namespace LiteCharms.Features.Shop.Postgres.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Init : Migration
|
public partial class Init : Migration
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
@@ -9,7 +9,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
namespace LiteCharms.Features.Shop.Postgres.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ShopDbContext))]
|
[DbContext(typeof(ShopDbContext))]
|
||||||
[Migration("20260514004002_UsedStringTableNames")]
|
[Migration("20260514004002_UsedStringTableNames")]
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
namespace LiteCharms.Features.Shop.Postgres.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class UsedStringTableNames : Migration
|
public partial class UsedStringTableNames : Migration
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
@@ -9,7 +9,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
namespace LiteCharms.Features.Shop.Postgres.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ShopDbContext))]
|
[DbContext(typeof(ShopDbContext))]
|
||||||
[Migration("20260515055221_FixedLeadCustomerRelationship")]
|
[Migration("20260515055221_FixedLeadCustomerRelationship")]
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
namespace LiteCharms.Features.Shop.Postgres.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class FixedLeadCustomerRelationship : Migration
|
public partial class FixedLeadCustomerRelationship : Migration
|
||||||
+3
-15
@@ -1,7 +1,6 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
using LiteCharms.Features.TechShop.Postgres;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using LiteCharms.Features.TechShop.Products.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
@@ -9,7 +8,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
namespace LiteCharms.Features.Shop.Postgres.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ShopDbContext))]
|
[DbContext(typeof(ShopDbContext))]
|
||||||
partial class ShopDbContextModelSnapshot : ModelSnapshot
|
partial class ShopDbContextModelSnapshot : ModelSnapshot
|
||||||
@@ -387,12 +386,7 @@ namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
|||||||
b.Property<bool>("Active")
|
b.Property<bool>("Active")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
.HasDefaultValue(false);
|
.HasDefaultValue(true);
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasDefaultValueSql("now()");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
@@ -403,9 +397,6 @@ namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
|||||||
.HasMaxLength(2048)
|
.HasMaxLength(2048)
|
||||||
.HasColumnType("character varying(2048)");
|
.HasColumnType("character varying(2048)");
|
||||||
|
|
||||||
b.Property<ProductMetadata>("Metadata")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -418,9 +409,6 @@ namespace LiteCharms.Features.TechShop.Postgres.Migrations
|
|||||||
b.PrimitiveCollection<string>("Thumbnails")
|
b.PrimitiveCollection<string>("Thumbnails")
|
||||||
.HasColumnType("jsonb");
|
.HasColumnType("jsonb");
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Products", (string)null);
|
b.ToTable("Products", (string)null);
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user