f6fa070067
Implemented complete CQRS pattern for System Configuration management:
Commands:
- SetConfigurationValueCommand: Create or update configurations with history tracking
- DeactivateConfigurationCommand: Deactivate configurations with audit trail
Queries:
- GetConfigurationByKeyQuery: Retrieve configuration by Scope and Key
- GetAllConfigurationsQuery: List all configurations with filters and pagination
- GetConfigurationHistoryQuery: View complete audit history for any configuration
Features:
- All commands include FluentValidation validators
- History recording to SystemConfigurationHistory table
- Pagination support for list queries
- DTOs for clean data transfer
- Null-safe implementations
Updated:
- IApplicationDbContext: Added 11 new DbSets for network-club entities
- GlobalUsings: Added new entity namespaces
Build Status: ✅ Success (0 errors, 184 warnings in legacy code)
26 lines
924 B
C#
26 lines
924 B
C#
namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetAllConfigurations;
|
|
|
|
public class GetAllConfigurationsQueryValidator : AbstractValidator<GetAllConfigurationsQuery>
|
|
{
|
|
public GetAllConfigurationsQueryValidator()
|
|
{
|
|
RuleFor(x => x.Filter.Scope)
|
|
.IsInEnum()
|
|
.WithMessage("محدوده تنظیمات معتبر نیست")
|
|
.When(x => x.Filter?.Scope != null);
|
|
}
|
|
|
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
|
{
|
|
var result = await ValidateAsync(
|
|
ValidationContext<GetAllConfigurationsQuery>.CreateWithOptions(
|
|
(GetAllConfigurationsQuery)model,
|
|
x => x.IncludeProperties(propertyName)));
|
|
|
|
if (result.IsValid)
|
|
return Array.Empty<string>();
|
|
|
|
return result.Errors.Select(e => e.ErrorMessage);
|
|
};
|
|
}
|