In progress
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
using ColaFlow.Modules.Identity.Application.Dtos;
|
||||
using MediatR;
|
||||
|
||||
namespace ColaFlow.Modules.Identity.Application.Queries.GetTenantBySlug;
|
||||
|
||||
public record GetTenantBySlugQuery(string Slug) : IRequest<TenantDto?>;
|
||||
@@ -0,0 +1,38 @@
|
||||
using ColaFlow.Modules.Identity.Application.Dtos;
|
||||
using ColaFlow.Modules.Identity.Domain.Aggregates.Tenants;
|
||||
using ColaFlow.Modules.Identity.Domain.Repositories;
|
||||
using MediatR;
|
||||
|
||||
namespace ColaFlow.Modules.Identity.Application.Queries.GetTenantBySlug;
|
||||
|
||||
public class GetTenantBySlugQueryHandler : IRequestHandler<GetTenantBySlugQuery, TenantDto?>
|
||||
{
|
||||
private readonly ITenantRepository _tenantRepository;
|
||||
|
||||
public GetTenantBySlugQueryHandler(ITenantRepository tenantRepository)
|
||||
{
|
||||
_tenantRepository = tenantRepository;
|
||||
}
|
||||
|
||||
public async Task<TenantDto?> Handle(GetTenantBySlugQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var slug = TenantSlug.Create(request.Slug);
|
||||
var tenant = await _tenantRepository.GetBySlugAsync(slug, cancellationToken);
|
||||
|
||||
if (tenant == null)
|
||||
return null;
|
||||
|
||||
return new TenantDto
|
||||
{
|
||||
Id = tenant.Id,
|
||||
Name = tenant.Name.Value,
|
||||
Slug = tenant.Slug.Value,
|
||||
Status = tenant.Status.ToString(),
|
||||
Plan = tenant.Plan.ToString(),
|
||||
SsoEnabled = tenant.SsoConfig != null,
|
||||
SsoProvider = tenant.SsoConfig?.Provider.ToString(),
|
||||
CreatedAt = tenant.CreatedAt,
|
||||
UpdatedAt = tenant.UpdatedAt ?? tenant.CreatedAt
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user