Files
PnvPanel/backend/src/PnvPanel.Application/Admin/Billing/GetBillingSettingsQueryHandler.cs
T
Leonid Pershin b05b76f32f
CI / Backend (build + test) (push) Failing after 1m28s
CI / Frontend (lint + typecheck + build) (push) Successful in 47s
Refactor messaging system to utilize LiteCqrs library
- Replaced instances of the previous messaging system with LiteCqrs across various application components, enhancing the CQRS implementation.
- Updated dependency injection to register LiteCqrs services and behaviors, streamlining command and query handling.
- Adjusted multiple command and query handlers to align with the new messaging framework, ensuring consistent functionality and improved maintainability.
- Added LiteCqrs package reference in the project file for better dependency management.
2026-07-24 04:16:38 +03:00

29 lines
1.0 KiB
C#

using Microsoft.EntityFrameworkCore;
using PnvPanel.Application.Common.Interfaces;
using LiteCqrs;
using PnvPanel.Application.Common.Models;
using PnvPanel.Domain.Billing;
namespace PnvPanel.Application.Admin.Billing;
public sealed class GetBillingSettingsQueryHandler(IAppDbContext dbContext)
: IQueryHandler<GetBillingSettingsQuery, Result<BillingSettingsDto>>
{
public async Task<Result<BillingSettingsDto>> Handle(
GetBillingSettingsQuery query,
CancellationToken cancellationToken
)
{
var settings = await dbContext
.BillingSettings.AsNoTracking()
.FirstOrDefaultAsync(cancellationToken);
// Ещё не сохранялось ни разу — отдаём дефолты, а не ошибку (см. PricingSettings).
return Result.Success(
settings is null
? new BillingSettingsDto(string.Empty, BillingSettings.DefaultGraceDays, false)
: BillingSettingsDto.FromDomain(settings)
);
}
}