mirror of
https://github.com/alex289/CleanArchitecture.git
synced 2025-06-29 18:21:08 +00:00
chore: Code Cleanup
This commit is contained in:
parent
619fa02ab3
commit
b355aeb8ff
@ -15,8 +15,8 @@ namespace CleanArchitecture.Api.BackgroundServices;
|
|||||||
|
|
||||||
public sealed class SetInactiveUsersService : BackgroundService
|
public sealed class SetInactiveUsersService : BackgroundService
|
||||||
{
|
{
|
||||||
private readonly IServiceProvider _serviceProvider;
|
|
||||||
private readonly ILogger<SetInactiveUsersService> _logger;
|
private readonly ILogger<SetInactiveUsersService> _logger;
|
||||||
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
|
||||||
public SetInactiveUsersService(
|
public SetInactiveUsersService(
|
||||||
IServiceProvider serviceProvider,
|
IServiceProvider serviceProvider,
|
||||||
@ -55,7 +55,7 @@ public sealed class SetInactiveUsersService : BackgroundService
|
|||||||
{
|
{
|
||||||
user.SetInactive();
|
user.SetInactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await context.SaveChangesAsync(stoppingToken);
|
await context.SaveChangesAsync(stoppingToken);
|
||||||
@ -64,7 +64,7 @@ public sealed class SetInactiveUsersService : BackgroundService
|
|||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error while setting users to inactive");
|
_logger.LogError(ex, "Error while setting users to inactive");
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(TimeSpan.FromDays(1), stoppingToken);
|
await Task.Delay(TimeSpan.FromDays(1), stoppingToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,29 +7,29 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.ApplicationStatus" Version="7.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.ApplicationStatus" Version="7.0.0"/>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="7.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="7.0.0"/>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="7.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="7.0.0"/>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="7.0.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="7.0.0"/>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="7.1.0" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="7.1.0"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.10"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10"/>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.10">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.10">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.10"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="7.0.10" />
|
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="7.0.10"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="7.0.10" />
|
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="7.0.10"/>
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Application\CleanArchitecture.Application.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Application\CleanArchitecture.Application.csproj"/>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj"/>
|
||||||
<ProjectReference Include="..\CleanArchitecture.gRPC\CleanArchitecture.gRPC.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.gRPC\CleanArchitecture.gRPC.csproj"/>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -35,7 +35,7 @@ if (builder.Environment.IsProduction())
|
|||||||
var host = rabbitMqConfig["Host"]!;
|
var host = rabbitMqConfig["Host"]!;
|
||||||
var username = rabbitMqConfig["Username"]!;
|
var username = rabbitMqConfig["Username"]!;
|
||||||
var password = rabbitMqConfig["Password"]!;
|
var password = rabbitMqConfig["Password"]!;
|
||||||
|
|
||||||
builder.Services
|
builder.Services
|
||||||
.AddHealthChecks()
|
.AddHealthChecks()
|
||||||
.AddSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")!)
|
.AddSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")!)
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
|
||||||
<PackageReference Include="MockQueryable.NSubstitute" Version="7.0.0" />
|
<PackageReference Include="MockQueryable.NSubstitute" Version="7.0.0"/>
|
||||||
<PackageReference Include="NSubstitute" Version="5.0.0" />
|
<PackageReference Include="NSubstitute" Version="5.0.0"/>
|
||||||
<PackageReference Include="xunit" Version="2.5.0" />
|
<PackageReference Include="xunit" Version="2.5.0"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
@ -24,8 +24,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Application\CleanArchitecture.Application.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Application\CleanArchitecture.Application.csproj"/>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -32,7 +32,7 @@ public sealed class GetAllTenantsQueryHandlerTests
|
|||||||
result.PageSize.Should().Be(query.PageSize);
|
result.PageSize.Should().Be(query.PageSize);
|
||||||
result.Page.Should().Be(query.Page);
|
result.Page.Should().Be(query.Page);
|
||||||
result.Count.Should().Be(1);
|
result.Count.Should().Be(1);
|
||||||
|
|
||||||
tenant.Should().BeEquivalentTo(result.Items.First());
|
tenant.Should().BeEquivalentTo(result.Items.First());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public sealed class GetAllTenantsQueryHandlerTests
|
|||||||
public async Task Should_Not_Get_Deleted_Tenant()
|
public async Task Should_Not_Get_Deleted_Tenant()
|
||||||
{
|
{
|
||||||
_fixture.SetupTenant(true);
|
_fixture.SetupTenant(true);
|
||||||
|
|
||||||
var query = new PageQuery
|
var query = new PageQuery
|
||||||
{
|
{
|
||||||
PageSize = 10,
|
PageSize = 10,
|
||||||
@ -50,7 +50,7 @@ public sealed class GetAllTenantsQueryHandlerTests
|
|||||||
var result = await _fixture.QueryHandler.Handle(
|
var result = await _fixture.QueryHandler.Handle(
|
||||||
new GetAllTenantsQuery(query),
|
new GetAllTenantsQuery(query),
|
||||||
default);
|
default);
|
||||||
|
|
||||||
result.PageSize.Should().Be(query.PageSize);
|
result.PageSize.Should().Be(query.PageSize);
|
||||||
result.Page.Should().Be(query.Page);
|
result.Page.Should().Be(query.Page);
|
||||||
result.Count.Should().Be(0);
|
result.Count.Should().Be(0);
|
||||||
|
@ -16,7 +16,7 @@ public sealed class GetAllUsersQueryHandlerTests
|
|||||||
public async Task Should_Get_All_Users()
|
public async Task Should_Get_All_Users()
|
||||||
{
|
{
|
||||||
var user = _fixture.SetupUserAsync();
|
var user = _fixture.SetupUserAsync();
|
||||||
|
|
||||||
var query = new PageQuery
|
var query = new PageQuery
|
||||||
{
|
{
|
||||||
PageSize = 1,
|
PageSize = 1,
|
||||||
@ -28,7 +28,7 @@ public sealed class GetAllUsersQueryHandlerTests
|
|||||||
default);
|
default);
|
||||||
|
|
||||||
_fixture.VerifyNoDomainNotification();
|
_fixture.VerifyNoDomainNotification();
|
||||||
|
|
||||||
result.PageSize.Should().Be(query.PageSize);
|
result.PageSize.Should().Be(query.PageSize);
|
||||||
result.Page.Should().Be(query.Page);
|
result.Page.Should().Be(query.Page);
|
||||||
result.Count.Should().Be(1);
|
result.Count.Should().Be(1);
|
||||||
@ -43,7 +43,7 @@ public sealed class GetAllUsersQueryHandlerTests
|
|||||||
public async Task Should_Not_Get_Deleted_Users()
|
public async Task Should_Not_Get_Deleted_Users()
|
||||||
{
|
{
|
||||||
_fixture.SetupDeletedUserAsync();
|
_fixture.SetupDeletedUserAsync();
|
||||||
|
|
||||||
var query = new PageQuery
|
var query = new PageQuery
|
||||||
{
|
{
|
||||||
PageSize = 10,
|
PageSize = 10,
|
||||||
@ -55,7 +55,7 @@ public sealed class GetAllUsersQueryHandlerTests
|
|||||||
default);
|
default);
|
||||||
|
|
||||||
_fixture.VerifyNoDomainNotification();
|
_fixture.VerifyNoDomainNotification();
|
||||||
|
|
||||||
result.PageSize.Should().Be(query.PageSize);
|
result.PageSize.Should().Be(query.PageSize);
|
||||||
result.Page.Should().Be(query.Page);
|
result.Page.Should().Be(query.Page);
|
||||||
result.Count.Should().Be(0);
|
result.Count.Should().Be(0);
|
||||||
|
@ -27,21 +27,21 @@ public sealed class GetAllTenantsQueryHandler :
|
|||||||
.GetAllNoTracking()
|
.GetAllNoTracking()
|
||||||
.Include(x => x.Users)
|
.Include(x => x.Users)
|
||||||
.Where(x => !x.Deleted);
|
.Where(x => !x.Deleted);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(request.SearchTerm))
|
if (!string.IsNullOrWhiteSpace(request.SearchTerm))
|
||||||
{
|
{
|
||||||
tenantsQuery = tenantsQuery.Where(tenant =>
|
tenantsQuery = tenantsQuery.Where(tenant =>
|
||||||
tenant.Name.Contains(request.SearchTerm));
|
tenant.Name.Contains(request.SearchTerm));
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalCount = await tenantsQuery.CountAsync(cancellationToken);
|
var totalCount = await tenantsQuery.CountAsync(cancellationToken);
|
||||||
|
|
||||||
var tenants = await tenantsQuery
|
var tenants = await tenantsQuery
|
||||||
.Skip((request.Query.Page - 1) * request.Query.PageSize)
|
.Skip((request.Query.Page - 1) * request.Query.PageSize)
|
||||||
.Take(request.Query.PageSize)
|
.Take(request.Query.PageSize)
|
||||||
.Select(tenant => TenantViewModel.FromTenant(tenant))
|
.Select(tenant => TenantViewModel.FromTenant(tenant))
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
return new PagedResult<TenantViewModel>(
|
return new PagedResult<TenantViewModel>(
|
||||||
totalCount, tenants, request.Query.Page, request.Query.PageSize);
|
totalCount, tenants, request.Query.Page, request.Query.PageSize);
|
||||||
}
|
}
|
||||||
|
@ -29,14 +29,14 @@ public sealed class GetAllUsersQueryHandler :
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(request.SearchTerm))
|
if (!string.IsNullOrWhiteSpace(request.SearchTerm))
|
||||||
{
|
{
|
||||||
usersQuery = usersQuery.Where(user =>
|
usersQuery = usersQuery.Where(user =>
|
||||||
user.Email.Contains(request.SearchTerm) ||
|
user.Email.Contains(request.SearchTerm) ||
|
||||||
user.FirstName.Contains(request.SearchTerm) ||
|
user.FirstName.Contains(request.SearchTerm) ||
|
||||||
user.LastName.Contains(request.SearchTerm));
|
user.LastName.Contains(request.SearchTerm));
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalCount = await usersQuery.CountAsync(cancellationToken);
|
var totalCount = await usersQuery.CountAsync(cancellationToken);
|
||||||
|
|
||||||
var users = await usersQuery
|
var users = await usersQuery
|
||||||
.Skip((request.Query.Page - 1) * request.Query.PageSize)
|
.Skip((request.Query.Page - 1) * request.Query.PageSize)
|
||||||
.Take(request.Query.PageSize)
|
.Take(request.Query.PageSize)
|
||||||
|
@ -60,7 +60,7 @@ public sealed class TenantService : ITenantService
|
|||||||
SlidingExpiration = TimeSpan.FromDays(3),
|
SlidingExpiration = TimeSpan.FromDays(3),
|
||||||
AbsoluteExpiration = DateTimeOffset.Now.AddDays(30)
|
AbsoluteExpiration = DateTimeOffset.Now.AddDays(30)
|
||||||
});
|
});
|
||||||
|
|
||||||
return cachedTenant;
|
return cachedTenant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CleanArchitecture.Application.Interfaces;
|
using CleanArchitecture.Application.Interfaces;
|
||||||
using CleanArchitecture.Application.Queries.Users.GetAll;
|
using CleanArchitecture.Application.Queries.Users.GetAll;
|
||||||
|
@ -4,14 +4,15 @@ namespace CleanArchitecture.Application.ViewModels;
|
|||||||
|
|
||||||
public sealed class PageQuery
|
public sealed class PageQuery
|
||||||
{
|
{
|
||||||
|
private int _page = 1;
|
||||||
private int _pageSize = 10;
|
private int _pageSize = 10;
|
||||||
|
|
||||||
public int PageSize
|
public int PageSize
|
||||||
{
|
{
|
||||||
get => _pageSize;
|
get => _pageSize;
|
||||||
set => _pageSize = Math.Max(0, value);
|
set => _pageSize = Math.Max(0, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _page = 1;
|
|
||||||
public int Page
|
public int Page
|
||||||
{
|
{
|
||||||
get => _page;
|
get => _page;
|
||||||
|
@ -23,7 +23,6 @@ public sealed class PagedResult<T>
|
|||||||
// used by json deserializer
|
// used by json deserializer
|
||||||
private PagedResult()
|
private PagedResult()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PagedResult<T> Empty()
|
public static PagedResult<T> Empty()
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3"/>
|
||||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
|
||||||
<PackageReference Include="NSubstitute" Version="5.0.0" />
|
<PackageReference Include="NSubstitute" Version="5.0.0"/>
|
||||||
<PackageReference Include="xunit" Version="2.5.0" />
|
<PackageReference Include="xunit" Version="2.5.0"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -61,7 +61,7 @@ public sealed class CreateUserCommandHandlerTests
|
|||||||
DomainErrorCodes.User.UserAlreadyExists,
|
DomainErrorCodes.User.UserAlreadyExists,
|
||||||
$"There is already a user with Id {command.UserId}");
|
$"There is already a user with Id {command.UserId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Should_Not_Create_Already_Existing_Email()
|
public void Should_Not_Create_Already_Existing_Email()
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ public sealed class DeleteUserCommandHandlerTests
|
|||||||
ErrorCodes.ObjectNotFound,
|
ErrorCodes.ObjectNotFound,
|
||||||
$"There is no user with Id {command.UserId}");
|
$"There is no user with Id {command.UserId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Should_Not_Delete_User_Insufficient_Permissions()
|
public void Should_Not_Delete_User_Insufficient_Permissions()
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ public sealed class DeleteUserCommandTestFixture : CommandHandlerFixtureBase
|
|||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupCurrentUser()
|
public void SetupCurrentUser()
|
||||||
{
|
{
|
||||||
User.GetUserRole().Returns(UserRole.User);
|
User.GetUserRole().Returns(UserRole.User);
|
||||||
|
@ -5,9 +5,13 @@ namespace CleanArchitecture.Domain;
|
|||||||
|
|
||||||
public static class CacheKeyGenerator
|
public static class CacheKeyGenerator
|
||||||
{
|
{
|
||||||
public static string GetEntityCacheKey<TEntity>(TEntity entity) where TEntity : Entity =>
|
public static string GetEntityCacheKey<TEntity>(TEntity entity) where TEntity : Entity
|
||||||
$"{typeof(TEntity)}-{entity.Id}";
|
{
|
||||||
|
return $"{typeof(TEntity)}-{entity.Id}";
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetEntityCacheKey<TEntity>(Guid id) where TEntity : Entity =>
|
public static string GetEntityCacheKey<TEntity>(Guid id) where TEntity : Entity
|
||||||
$"{typeof(TEntity)}-{id}";
|
{
|
||||||
|
return $"{typeof(TEntity)}-{id}";
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,16 +10,16 @@
|
|||||||
<PackageReference Include="FluentValidation" Version="11.7.1"/>
|
<PackageReference Include="FluentValidation" Version="11.7.1"/>
|
||||||
<PackageReference Include="MediatR" Version="12.1.1"/>
|
<PackageReference Include="MediatR" Version="12.1.1"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1"/>
|
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1"/>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
|
||||||
<PackageReference Include="RabbitMQ.Client" Version="6.5.0" />
|
<PackageReference Include="RabbitMQ.Client" Version="6.5.0"/>
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.32.1"/>
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.32.1"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Shared\CleanArchitecture.Shared.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Shared\CleanArchitecture.Shared.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -68,7 +68,7 @@ public sealed class LoginUserCommandHandler : CommandHandlerBase,
|
|||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
user.SetActive();
|
user.SetActive();
|
||||||
user.SetLastLoggedinDate(DateTimeOffset.Now);
|
user.SetLastLoggedinDate(DateTimeOffset.Now);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class User : Entity
|
|||||||
{
|
{
|
||||||
TenantId = tenantId;
|
TenantId = tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetLastLoggedinDate(DateTimeOffset lastLoggedinDate)
|
public void SetLastLoggedinDate(DateTimeOffset lastLoggedinDate)
|
||||||
{
|
{
|
||||||
LastLoggedinDate = lastLoggedinDate;
|
LastLoggedinDate = lastLoggedinDate;
|
||||||
@ -76,7 +76,7 @@ public class User : Entity
|
|||||||
{
|
{
|
||||||
Status = UserStatus.Inactive;
|
Status = UserStatus.Inactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetActive()
|
public void SetActive()
|
||||||
{
|
{
|
||||||
Status = UserStatus.Active;
|
Status = UserStatus.Active;
|
||||||
|
@ -39,7 +39,7 @@ public static class ServiceCollectionExtension
|
|||||||
{
|
{
|
||||||
// Fanout
|
// Fanout
|
||||||
services.AddScoped<IFanoutEventHandler, FanoutEventHandler>();
|
services.AddScoped<IFanoutEventHandler, FanoutEventHandler>();
|
||||||
|
|
||||||
// User
|
// User
|
||||||
services.AddScoped<INotificationHandler<UserCreatedEvent>, UserEventHandler>();
|
services.AddScoped<INotificationHandler<UserCreatedEvent>, UserEventHandler>();
|
||||||
services.AddScoped<INotificationHandler<UserUpdatedEvent>, UserEventHandler>();
|
services.AddScoped<INotificationHandler<UserUpdatedEvent>, UserEventHandler>();
|
||||||
|
@ -13,6 +13,7 @@ namespace CleanArchitecture.Domain.Rabbitmq;
|
|||||||
|
|
||||||
public sealed class RabbitMqHandler : BackgroundService
|
public sealed class RabbitMqHandler : BackgroundService
|
||||||
{
|
{
|
||||||
|
private readonly IModel? _channel;
|
||||||
private readonly RabbitMqConfiguration _configuration;
|
private readonly RabbitMqConfiguration _configuration;
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<string, List<ConsumeEventHandler>> _consumers = new();
|
private readonly ConcurrentDictionary<string, List<ConsumeEventHandler>> _consumers = new();
|
||||||
@ -21,8 +22,6 @@ public sealed class RabbitMqHandler : BackgroundService
|
|||||||
|
|
||||||
private readonly ConcurrentQueue<IRabbitMqAction> _pendingActions = new();
|
private readonly ConcurrentQueue<IRabbitMqAction> _pendingActions = new();
|
||||||
|
|
||||||
private readonly IModel? _channel;
|
|
||||||
|
|
||||||
public RabbitMqHandler(
|
public RabbitMqHandler(
|
||||||
RabbitMqConfiguration configuration,
|
RabbitMqConfiguration configuration,
|
||||||
ILogger<RabbitMqHandler> logger)
|
ILogger<RabbitMqHandler> logger)
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
|
||||||
<PackageReference Include="NSubstitute" Version="5.0.0" />
|
<PackageReference Include="NSubstitute" Version="5.0.0"/>
|
||||||
<PackageReference Include="xunit" Version="2.5.0" />
|
<PackageReference Include="xunit" Version="2.5.0"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj"/>
|
<ProjectReference Include="..\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj"/>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Shared\CleanArchitecture.Shared.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Shared\CleanArchitecture.Shared.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -11,8 +11,8 @@ namespace CleanArchitecture.Infrastructure;
|
|||||||
public sealed class InMemoryBus : IMediatorHandler
|
public sealed class InMemoryBus : IMediatorHandler
|
||||||
{
|
{
|
||||||
private readonly IDomainEventStore _domainEventStore;
|
private readonly IDomainEventStore _domainEventStore;
|
||||||
private readonly IMediator _mediator;
|
|
||||||
private readonly IFanoutEventHandler _fanoutEventHandler;
|
private readonly IFanoutEventHandler _fanoutEventHandler;
|
||||||
|
private readonly IMediator _mediator;
|
||||||
|
|
||||||
public InMemoryBus(
|
public InMemoryBus(
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
@ -34,7 +34,7 @@ public sealed class InMemoryBus : IMediatorHandler
|
|||||||
await _domainEventStore.SaveAsync(@event);
|
await _domainEventStore.SaveAsync(@event);
|
||||||
|
|
||||||
await _mediator.Publish(@event);
|
await _mediator.Publish(@event);
|
||||||
|
|
||||||
await _fanoutEventHandler.HandleDomainEventAsync(@event);
|
await _fanoutEventHandler.HandleDomainEventAsync(@event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.10"/>
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.10" />
|
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.10"/>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.10"/>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.10"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
|
||||||
<PackageReference Include="xunit" Version="2.5.0" />
|
<PackageReference Include="xunit" Version="2.5.0"/>
|
||||||
<PackageReference Include="Xunit.Priority" Version="1.1.6" />
|
<PackageReference Include="Xunit.Priority" Version="1.1.6"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
@ -27,8 +27,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Api\CleanArchitecture.Api.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Api\CleanArchitecture.Api.csproj"/>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,16 +6,16 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Protobuf Include="Users\Models.proto" GrpcServices="Both" />
|
<Protobuf Include="Users\Models.proto" GrpcServices="Both"/>
|
||||||
<Protobuf Include="Users\UsersApi.proto" GrpcServices="Both" />
|
<Protobuf Include="Users\UsersApi.proto" GrpcServices="Both"/>
|
||||||
<Protobuf Include="Tenants\Models.proto" GrpcServices="Both" />
|
<Protobuf Include="Tenants\Models.proto" GrpcServices="Both"/>
|
||||||
<Protobuf Include="Tenants\TenantsApi.proto" GrpcServices="Both" />
|
<Protobuf Include="Tenants\TenantsApi.proto" GrpcServices="Both"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Google.Protobuf" Version="3.24.2" />
|
<PackageReference Include="Google.Protobuf" Version="3.24.2"/>
|
||||||
<PackageReference Include="Google.Protobuf.Tools" Version="3.24.2" />
|
<PackageReference Include="Google.Protobuf.Tools" Version="3.24.2"/>
|
||||||
<PackageReference Include="Grpc.AspNetCore" Version="2.56.0" />
|
<PackageReference Include="Grpc.AspNetCore" Version="2.56.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MediatR" Version="12.1.1" />
|
<PackageReference Include="MediatR" Version="12.1.1"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
|
||||||
<PackageReference Include="MockQueryable.NSubstitute" Version="7.0.0" />
|
<PackageReference Include="MockQueryable.NSubstitute" Version="7.0.0"/>
|
||||||
<PackageReference Include="NSubstitute" Version="5.0.0" />
|
<PackageReference Include="NSubstitute" Version="5.0.0"/>
|
||||||
<PackageReference Include="xunit" Version="2.5.0" />
|
<PackageReference Include="xunit" Version="2.5.0"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
@ -24,9 +24,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Application\CleanArchitecture.Application.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Application\CleanArchitecture.Application.csproj"/>
|
||||||
<ProjectReference Include="..\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj"/>
|
||||||
<ProjectReference Include="..\CleanArchitecture.gRPC\CleanArchitecture.gRPC.csproj" />
|
<ProjectReference Include="..\CleanArchitecture.gRPC\CleanArchitecture.gRPC.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user