This commit is contained in:
King
2025-09-28 15:24:13 +03:30
parent 514b3a5975
commit 4241523443
222 changed files with 8139 additions and 0 deletions

View File

@@ -12045,6 +12045,503 @@
"filestreamPartitionScheme": "", "filestreamPartitionScheme": "",
"dataCompressions": [] "dataCompressions": []
} }
},
{
"objectType": "Table_MSSQL",
"name": "OtpService",
"comment": "",
"owner": "",
"isChangeTracking": false,
"isTrackColumnsUpdated": false,
"oldName": "",
"isSystemTable": false,
"createTime": "",
"modifyTime": "",
"objectID": 0,
"numberOfRows": 0,
"identityCurrent": 0,
"dataLength": 0,
"indexLength": 0,
"fields": [
{
"objectType": "TableField_MSSQL",
"name": "SendOtp",
"type": "Command",
"size": 0,
"isNullable": "Yes",
"scale": 0,
"comment": "ارسال رمز پویا",
"computedExpression": "",
"defaultValue": "",
"defaultValueType": "Others",
"schema": "",
"userDefinedType": "",
"collate": "",
"isWithValues": false,
"isFilestream": false,
"isColumnSet": false,
"isPersisted": false,
"isSparse": false,
"isRowGUIDColumn": false,
"oldName": "SendOtp",
"computedBaseType": "",
"isDefaultConstraint": false,
"defaultConstraint": "",
"isIdentity": false,
"isExistingField": false,
"identitySeed": 0,
"identityIncrement": 0,
"identityIsNotForReplication": false
},
{
"objectType": "TableField_MSSQL",
"name": "VerifyOtpCode",
"type": "Command",
"size": 0,
"isNullable": "Yes",
"scale": 0,
"comment": "فعال سازی رمز پویا",
"computedExpression": "",
"defaultValue": "",
"defaultValueType": "Others",
"schema": "",
"userDefinedType": "",
"collate": "",
"isWithValues": false,
"isFilestream": false,
"isColumnSet": false,
"isPersisted": false,
"isSparse": false,
"isRowGUIDColumn": false,
"oldName": "VerifyOtpCode",
"computedBaseType": "",
"isDefaultConstraint": false,
"defaultConstraint": "",
"isIdentity": false,
"isExistingField": false,
"identitySeed": 0,
"identityIncrement": 0,
"identityIsNotForReplication": false
}
],
"indexes": [],
"foreignKeys": [
{
"objectType": "ForeignKey_MSSQL",
"name": "fk_OtpService_VerifyOtpCodeRequest_1",
"fields": [
"VerifyOtpCode"
],
"referencedSchema": "BackOffice",
"referencedTable": "VerifyOtpCodeRequest",
"referencedFields": [
"Mobile"
],
"onDelete": "",
"onUpdate": "",
"isNotForReplication": false,
"isEnabled": true,
"comment": "",
"sourceCardinality": "NoneRelationship",
"targetCardinality": "NoneRelationship",
"oldName": ""
},
{
"objectType": "ForeignKey_MSSQL",
"name": "fk_OtpService_VerifyOtpCodeResponse_1",
"fields": [
"VerifyOtpCode"
],
"referencedSchema": "BackOffice",
"referencedTable": "VerifyOtpCodeResponse",
"referencedFields": [
"Token"
],
"onDelete": "",
"onUpdate": "",
"isNotForReplication": false,
"isEnabled": true,
"comment": "",
"sourceCardinality": "NoneRelationship",
"targetCardinality": "NoneRelationship",
"oldName": ""
},
{
"objectType": "ForeignKey_MSSQL",
"name": "fk_OtpService_SendOtpRequest_1",
"fields": [
"SendOtp"
],
"referencedSchema": "BackOffice",
"referencedTable": "SendOtpRequest",
"referencedFields": [
"Mobile"
],
"onDelete": "",
"onUpdate": "",
"isNotForReplication": false,
"isEnabled": true,
"comment": "",
"sourceCardinality": "NoneRelationship",
"targetCardinality": "NoneRelationship",
"oldName": ""
}
],
"uniques": [],
"checks": [],
"triggers": [],
"storage": {
"objectType": "Storage_MSSQL",
"name": "",
"oldName": "",
"storageType": "Default",
"filegroup": "",
"textImageFilegroup": "",
"filestreamFilegroup": "",
"partitionScheme": "",
"partitionColumn": "",
"filestreamPartitionScheme": "",
"dataCompressions": []
}
},
{
"objectType": "Table_MSSQL",
"name": "VerifyOtpCodeRequest",
"comment": "ورودی فعال سازی رمز پویا",
"owner": "",
"isChangeTracking": false,
"isTrackColumnsUpdated": false,
"oldName": "",
"isSystemTable": false,
"createTime": "",
"modifyTime": "",
"objectID": 9803,
"numberOfRows": 0,
"identityCurrent": 0,
"dataLength": 0,
"indexLength": 0,
"fields": [
{
"objectType": "TableField_MSSQL",
"name": "Mobile",
"type": "nvarchar",
"size": -2147483648,
"isNullable": "No",
"scale": -2147483648,
"comment": "شماره موبایل",
"computedExpression": "",
"defaultValue": "",
"defaultValueType": "Others",
"schema": "",
"userDefinedType": "",
"collate": "",
"isWithValues": false,
"isFilestream": false,
"isColumnSet": false,
"isPersisted": false,
"isSparse": false,
"isRowGUIDColumn": false,
"oldName": "Mobile",
"computedBaseType": "",
"isDefaultConstraint": false,
"defaultConstraint": "",
"isIdentity": false,
"isExistingField": false,
"identitySeed": 0,
"identityIncrement": 0,
"identityIsNotForReplication": false
},
{
"objectType": "TableField_MSSQL",
"name": "Code",
"type": "nvarchar",
"size": -2147483648,
"isNullable": "No",
"scale": -2147483648,
"comment": "رمز پویا",
"computedExpression": "",
"defaultValue": "",
"defaultValueType": "Others",
"schema": "",
"userDefinedType": "",
"collate": "",
"isWithValues": false,
"isFilestream": false,
"isColumnSet": false,
"isPersisted": false,
"isSparse": false,
"isRowGUIDColumn": false,
"oldName": "Code",
"computedBaseType": "",
"isDefaultConstraint": false,
"defaultConstraint": "",
"isIdentity": false,
"isExistingField": false,
"identitySeed": 0,
"identityIncrement": 0,
"identityIsNotForReplication": false
},
{
"objectType": "TableField_MSSQL",
"name": "ParentId",
"type": "bigint",
"size": -2147483648,
"isNullable": "Yes",
"scale": -2147483648,
"comment": "شناسه پدر",
"computedExpression": "",
"defaultValue": "",
"defaultValueType": "Others",
"schema": "",
"userDefinedType": "",
"collate": "",
"isWithValues": false,
"isFilestream": false,
"isColumnSet": false,
"isPersisted": false,
"isSparse": false,
"isRowGUIDColumn": false,
"oldName": "ParentId",
"computedBaseType": "",
"isDefaultConstraint": false,
"defaultConstraint": "",
"isIdentity": false,
"isExistingField": false,
"identitySeed": 0,
"identityIncrement": 0,
"identityIsNotForReplication": false
}
],
"indexes": [],
"primaryKey": {
"objectType": "PrimaryKey_MSSQL",
"name": "_copy_10_copy_1_copy_1",
"fields": [],
"fillFactor": 0,
"oldName": "",
"isClustered": false,
"isPadded": false,
"noRecomputeStatistics": false,
"ignoreDuplicatedKeyValues": false,
"allowRowLocks": false,
"allowPageLocks": false,
"storage": {
"objectType": "Storage_MSSQL",
"name": "",
"oldName": "",
"storageType": "Default",
"filegroup": "",
"textImageFilegroup": "",
"filestreamFilegroup": "",
"partitionScheme": "",
"partitionColumn": "",
"filestreamPartitionScheme": "",
"dataCompressions": []
}
},
"foreignKeys": [],
"uniques": [],
"checks": [],
"triggers": [],
"storage": {
"objectType": "Storage_MSSQL",
"name": "",
"oldName": "",
"storageType": "Default",
"filegroup": "",
"textImageFilegroup": "",
"filestreamFilegroup": "",
"partitionScheme": "",
"partitionColumn": "",
"filestreamPartitionScheme": "",
"dataCompressions": []
}
},
{
"objectType": "Table_MSSQL",
"name": "SendOtpRequest",
"comment": "ورودی ارسال رمز پویا",
"owner": "",
"isChangeTracking": false,
"isTrackColumnsUpdated": false,
"oldName": "",
"isSystemTable": false,
"createTime": "",
"modifyTime": "",
"objectID": 9803,
"numberOfRows": 0,
"identityCurrent": 0,
"dataLength": 0,
"indexLength": 0,
"fields": [
{
"objectType": "TableField_MSSQL",
"name": "Mobile",
"type": "nvarchar",
"size": -2147483648,
"isNullable": "No",
"scale": -2147483648,
"comment": "شماره موبایل",
"computedExpression": "",
"defaultValue": "",
"defaultValueType": "Others",
"schema": "",
"userDefinedType": "",
"collate": "",
"isWithValues": false,
"isFilestream": false,
"isColumnSet": false,
"isPersisted": false,
"isSparse": false,
"isRowGUIDColumn": false,
"oldName": "Mobile",
"computedBaseType": "",
"isDefaultConstraint": false,
"defaultConstraint": "",
"isIdentity": false,
"isExistingField": false,
"identitySeed": 0,
"identityIncrement": 0,
"identityIsNotForReplication": false
}
],
"indexes": [],
"primaryKey": {
"objectType": "PrimaryKey_MSSQL",
"name": "_copy_10_copy_1",
"fields": [],
"fillFactor": 0,
"oldName": "",
"isClustered": false,
"isPadded": false,
"noRecomputeStatistics": false,
"ignoreDuplicatedKeyValues": false,
"allowRowLocks": false,
"allowPageLocks": false,
"storage": {
"objectType": "Storage_MSSQL",
"name": "",
"oldName": "",
"storageType": "Default",
"filegroup": "",
"textImageFilegroup": "",
"filestreamFilegroup": "",
"partitionScheme": "",
"partitionColumn": "",
"filestreamPartitionScheme": "",
"dataCompressions": []
}
},
"foreignKeys": [],
"uniques": [],
"checks": [],
"triggers": [],
"storage": {
"objectType": "Storage_MSSQL",
"name": "",
"oldName": "",
"storageType": "Default",
"filegroup": "",
"textImageFilegroup": "",
"filestreamFilegroup": "",
"partitionScheme": "",
"partitionColumn": "",
"filestreamPartitionScheme": "",
"dataCompressions": []
}
},
{
"objectType": "Table_MSSQL",
"name": "VerifyOtpCodeResponse",
"comment": "خروجی فعال سازی رمز پویا",
"owner": "",
"isChangeTracking": false,
"isTrackColumnsUpdated": false,
"oldName": "",
"isSystemTable": false,
"createTime": "",
"modifyTime": "",
"objectID": 9803,
"numberOfRows": 0,
"identityCurrent": 0,
"dataLength": 0,
"indexLength": 0,
"fields": [
{
"objectType": "TableField_MSSQL",
"name": "Token",
"type": "nvarchar",
"size": -2147483648,
"isNullable": "No",
"scale": -2147483648,
"comment": "توکن",
"computedExpression": "",
"defaultValue": "",
"defaultValueType": "Others",
"schema": "",
"userDefinedType": "",
"collate": "",
"isWithValues": false,
"isFilestream": false,
"isColumnSet": false,
"isPersisted": false,
"isSparse": false,
"isRowGUIDColumn": false,
"oldName": "Token",
"computedBaseType": "",
"isDefaultConstraint": false,
"defaultConstraint": "",
"isIdentity": false,
"isExistingField": false,
"identitySeed": 0,
"identityIncrement": 0,
"identityIsNotForReplication": false
}
],
"indexes": [],
"primaryKey": {
"objectType": "PrimaryKey_MSSQL",
"name": "_copy_10_copy_1_copy_1_copy_1",
"fields": [],
"fillFactor": 0,
"oldName": "",
"isClustered": false,
"isPadded": false,
"noRecomputeStatistics": false,
"ignoreDuplicatedKeyValues": false,
"allowRowLocks": false,
"allowPageLocks": false,
"storage": {
"objectType": "Storage_MSSQL",
"name": "",
"oldName": "",
"storageType": "Default",
"filegroup": "",
"textImageFilegroup": "",
"filestreamFilegroup": "",
"partitionScheme": "",
"partitionColumn": "",
"filestreamPartitionScheme": "",
"dataCompressions": []
}
},
"foreignKeys": [],
"uniques": [],
"checks": [],
"triggers": [],
"storage": {
"objectType": "Storage_MSSQL",
"name": "",
"oldName": "",
"storageType": "Default",
"filegroup": "",
"textImageFilegroup": "",
"filestreamFilegroup": "",
"partitionScheme": "",
"partitionColumn": "",
"filestreamPartitionScheme": "",
"dataCompressions": []
}
} }
], ],
"views": [] "views": []
@@ -13138,6 +13635,70 @@
"b": 147, "b": 147,
"a": 1 "a": 1
} }
},
{
"type": "table",
"schemaName": "BackOffice",
"tableName": "OtpService",
"x": 5740,
"y": 20,
"width": 310,
"height": 120,
"isBold": false,
"titleColor": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
}
},
{
"type": "table",
"schemaName": "BackOffice",
"tableName": "VerifyOtpCodeRequest",
"x": 6100,
"y": 20,
"width": 310,
"height": 130,
"isBold": false,
"titleColor": {
"r": 255,
"g": 214,
"b": 147,
"a": 1
}
},
{
"type": "table",
"schemaName": "BackOffice",
"tableName": "SendOtpRequest",
"x": 5380,
"y": 30,
"width": 310,
"height": 100,
"isBold": false,
"titleColor": {
"r": 255,
"g": 214,
"b": 147,
"a": 1
}
},
{
"type": "table",
"schemaName": "BackOffice",
"tableName": "VerifyOtpCodeResponse",
"x": 5740,
"y": 190,
"width": 310,
"height": 100,
"isBold": false,
"titleColor": {
"r": 200,
"g": 255,
"b": 160,
"a": 1
}
} }
], ],
"layers": [], "layers": [],
@@ -15417,6 +15978,108 @@
"isFontItalic": false, "isFontItalic": false,
"isVisible": false "isVisible": false
} }
},
{
"name": "fk_OtpService_VerifyOtpCodeRequest_1",
"sourceTableName": "OtpService",
"sourceSchemaName": "BackOffice",
"lineWidth": 1,
"visible": true,
"vertices": [
{
"x": 6065,
"y": 80
},
{
"x": 6085,
"y": 80
}
],
"label": {
"x": 6061,
"y": 52,
"width": 270,
"height": 30,
"fontName": "Arial Unicode MS",
"fontSize": 14,
"fontColor": {
"r": 204,
"g": 204,
"b": 204,
"a": 1
},
"isFontBold": false,
"isFontItalic": false,
"isVisible": false
}
},
{
"name": "fk_OtpService_VerifyOtpCodeResponse_1",
"sourceTableName": "OtpService",
"sourceSchemaName": "BackOffice",
"lineWidth": 1,
"visible": true,
"vertices": [
{
"x": 5880,
"y": 155
},
{
"x": 5880,
"y": 175
}
],
"label": {
"x": 5882,
"y": 105,
"width": 280,
"height": 30,
"fontName": "Arial Unicode MS",
"fontSize": 14,
"fontColor": {
"r": 204,
"g": 204,
"b": 204,
"a": 1
},
"isFontBold": false,
"isFontItalic": false,
"isVisible": false
}
},
{
"name": "fk_OtpService_SendOtpRequest_1",
"sourceTableName": "OtpService",
"sourceSchemaName": "BackOffice",
"lineWidth": 1,
"visible": true,
"vertices": [
{
"x": 5725,
"y": 80
},
{
"x": 5705,
"y": 80
}
],
"label": {
"x": 5735,
"y": 42,
"width": 231,
"height": 30,
"fontName": "Arial Unicode MS",
"fontSize": 14,
"fontColor": {
"r": 204,
"g": 204,
"b": 204,
"a": 1
},
"isFontBold": false,
"isFontItalic": false,
"isVisible": false
}
} }
], ],
"viewRelations": [] "viewRelations": []

View File

@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.116" />
<PackageReference Include="Mapster" Version="7.3.0" />
<PackageReference Include="Mapster.DependencyInjection" Version="1.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BackOffice.BFF.Domain\BackOffice.BFF.Domain.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,24 @@
using MediatR.Pipeline;
using Microsoft.Extensions.Logging;
namespace BackOffice.BFF.Application.Common.Behaviours;
public class LoggingBehaviour<TRequest> : IRequestPreProcessor<TRequest> where TRequest : notnull
{
private readonly ILogger _logger;
private readonly ICurrentUserService _currentUserService;
public LoggingBehaviour(ILogger<TRequest> logger, ICurrentUserService currentUserService)
{
_logger = logger;
_currentUserService = currentUserService;
}
public async Task Process(TRequest request, CancellationToken cancellationToken)
{
var requestName = typeof(TRequest).Name;
var userId = _currentUserService.UserId ?? string.Empty;
_logger.LogInformation("Request: {Name} {@UserId} {@Request}",
requestName, userId, request);
}
}

View File

@@ -0,0 +1,43 @@
using System.Diagnostics;
using MediatR;
using Microsoft.Extensions.Logging;
namespace BackOffice.BFF.Application.Common.Behaviours;
public class PerformanceBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
where TRequest : IRequest<TResponse>
{
private readonly Stopwatch _timer;
private readonly ILogger<TRequest> _logger;
private readonly ICurrentUserService _currentUserService;
public PerformanceBehaviour(ILogger<TRequest> logger, ICurrentUserService currentUserService)
{
_timer = new Stopwatch();
_logger = logger;
_currentUserService = currentUserService;
}
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next,
CancellationToken cancellationToken)
{
_timer.Start();
var response = await next();
_timer.Stop();
var elapsedMilliseconds = _timer.ElapsedMilliseconds;
if (elapsedMilliseconds > 500)
{
var requestName = typeof(TRequest).Name;
var userId = _currentUserService.UserId ?? string.Empty;
_logger.LogWarning("Long Running Request: {Name} ({ElapsedMilliseconds} milliseconds) {@UserId} {@Request}",
requestName, elapsedMilliseconds, userId, request);
}
return response;
}
}

View File

@@ -0,0 +1,31 @@
using Microsoft.Extensions.Logging;
namespace BackOffice.BFF.Application.Common.Behaviours;
public class UnhandledExceptionBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
where TRequest : IRequest<TResponse>
{
private readonly ILogger<TRequest> _logger;
public UnhandledExceptionBehaviour(ILogger<TRequest> logger)
{
_logger = logger;
}
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next,
CancellationToken cancellationToken)
{
try
{
return await next();
}
catch (Exception ex)
{
var requestName = typeof(TRequest).Name;
_logger.LogError(ex, "Request: Unhandled Exception for Request {Name} {@Request}", requestName, request);
throw;
}
}
}

View File

@@ -0,0 +1,37 @@
using ValidationException = BackOffice.BFF.Application.Common.Exceptions.ValidationException;
namespace BackOffice.BFF.Application.Common.Behaviours;
public class ValidationBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
where TRequest : IRequest<TResponse>
{
private readonly IEnumerable<IValidator<TRequest>> _validators;
public ValidationBehaviour(IEnumerable<IValidator<TRequest>> validators)
{
_validators = validators;
}
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next,
CancellationToken cancellationToken)
{
if (_validators.Any())
{
var context = new ValidationContext<TRequest>(request);
var validationResults = await Task.WhenAll(
_validators.Select(v =>
v.ValidateAsync(context, cancellationToken)));
var failures = validationResults
.Where(r => r.Errors.Any())
.SelectMany(r => r.Errors)
.ToList();
if (failures.Any())
throw new ValidationException(failures);
}
return await next();
}
}

View File

@@ -0,0 +1,29 @@
namespace BackOffice.BFF.Application.Common.Exceptions;
public class DuplicateException : Exception
{
public DuplicateException()
: base()
{
}
public DuplicateException(string message)
: base(message)
{
}
public DuplicateException(string message, Exception innerException)
: base(message, innerException)
{
}
public DuplicateException(string name, object key)
: base($"Entity \"{name}\" ({key}) already exists.")
{
}
public DuplicateException(string name, string field, object? key)
: base($"Entity \"{name}\" field \"{field}\" ({key}) already exists.")
{
}
}

View File

@@ -0,0 +1,8 @@
namespace BackOffice.BFF.Application.Common.Exceptions;
public class ForbiddenAccessException : Exception
{
public ForbiddenAccessException() : base()
{
}
}

View File

@@ -0,0 +1,24 @@
namespace BackOffice.BFF.Application.Common.Exceptions;
public class NotFoundException : Exception
{
public NotFoundException()
: base()
{
}
public NotFoundException(string message)
: base(message)
{
}
public NotFoundException(string message, Exception innerException)
: base(message, innerException)
{
}
public NotFoundException(string name, object key)
: base($"Entity \"{name}\" ({key}) was not found.")
{
}
}

View File

@@ -0,0 +1,22 @@
using FluentValidation.Results;
namespace BackOffice.BFF.Application.Common.Exceptions;
public class ValidationException : Exception
{
public ValidationException()
: base("One or more validation failures have occurred.")
{
Errors = new Dictionary<string, string[]>();
}
public ValidationException(IEnumerable<ValidationFailure> failures)
: this()
{
Errors = failures
.GroupBy(e => e.PropertyName, e => e.ErrorMessage)
.ToDictionary(failureGroup => failureGroup.Key, failureGroup => failureGroup.ToArray());
}
public IDictionary<string, string[]> Errors { get; }
}

View File

@@ -0,0 +1,17 @@
using CMSMicroservice.Protobuf.Protos.Package;
using FMSMicroservice.Protobuf.Protos.FileInfo;
namespace BackOffice.BFF.Application.Common.Interfaces;
public interface IApplicationContractContext
{
#region FM
FileInfoContract.FileInfoContractClient FileInfos { get; }
#endregion
#region CMS
PackageContract.PackageContractClient Packages { get; }
#endregion
}

View File

@@ -0,0 +1,6 @@
namespace BackOffice.BFF.Application.Common.Interfaces;
public interface ICurrentUserService
{
string? UserId { get; }
}

View File

@@ -0,0 +1,6 @@
namespace BackOffice.BFF.Application.Common.Interfaces;
public interface ITokenProvider
{
Task<string> GetTokenAsync();
}

View File

@@ -0,0 +1,64 @@
using System.Globalization;
namespace BackOffice.BFF.Application.Common.Mappings;
public class GeneralMapping : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
config.NewConfig<string, decimal>()
.MapWith(src => decimal.Parse(src));
config.NewConfig<decimal, string>()
.MapWith(src => src.ToString("R", new CultureInfo("en-us")));
config.NewConfig<decimal?, string>()
.MapWith(src => src == null ? string.Empty : src.Value.ToString("R", new CultureInfo("en-us")));
config.NewConfig<string, decimal?>()
.MapWith(src => string.IsNullOrEmpty(src) ? null : decimal.Parse(src));
config.NewConfig<Guid, string>()
.MapWith(src => src == Guid.Empty ? string.Empty : src.ToString());
config.NewConfig<string, Guid>()
.MapWith(src => string.IsNullOrEmpty(src) ? Guid.Empty : Guid.Parse(src));
config.NewConfig<string, Guid?>()
.MapWith(src => string.IsNullOrEmpty(src) ? null : Guid.Parse(src));
config.NewConfig<Timestamp, DateTime>()
.MapWith(src => src.ToDateTime());
config.NewConfig<Timestamp, DateTime?>()
.MapWith(src => src == null ? null : src.ToDateTime());
config.NewConfig<DateTime, Timestamp>()
.MapWith(src => Timestamp.FromDateTime(DateTime.SpecifyKind(src, DateTimeKind.Utc)));
config.NewConfig<DateTime?, Timestamp>()
.MapWith(src => src.HasValue ? Timestamp.FromDateTime(DateTime.SpecifyKind(src.Value, DateTimeKind.Utc)) : null);
config.NewConfig<Duration, TimeSpan>()
.MapWith(src => src.ToTimeSpan());
config.NewConfig<Duration, TimeSpan?>()
.MapWith(src => src == null ? null : src.ToTimeSpan());
config.NewConfig<TimeSpan, Duration>()
.MapWith(src => Duration.FromTimeSpan(src));
config.NewConfig<TimeSpan?, Duration>()
.MapWith(src => src.HasValue ? Duration.FromTimeSpan(src.Value) : null);
config.Default
.UseDestinationValue(member => member.SetterModifier == AccessModifier.None &&
member.Type.IsGenericType &&
member.Type.GetGenericTypeDefinition() == typeof(Google.Protobuf.Collections.RepeatedField<>));
config.NewConfig<Google.Protobuf.ByteString, byte[]>()
.MapWith(src => src.ToByteArray());
config.NewConfig<byte[], Google.Protobuf.ByteString>()
.MapWith(src => Google.Protobuf.ByteString.CopyFrom(src));
}
}

View File

@@ -0,0 +1,10 @@
namespace BackOffice.BFF.Application.Common.Mappings;
public class PackageProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,10 @@
namespace BackOffice.BFF.Application.Common.Mappings;
public class RoleProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,10 @@
namespace BackOffice.BFF.Application.Common.Mappings;
public class UserAddressProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,10 @@
namespace BackOffice.BFF.Application.Common.Mappings;
public class UserOrderProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,10 @@
namespace BackOffice.BFF.Application.Common.Mappings;
public class UserProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,10 @@
namespace BackOffice.BFF.Application.Common.Mappings;
public class UserRoleProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,22 @@
namespace BackOffice.BFF.Application.Common.Models;
public class MetaData
{
//صفحه جاری
public long CurrentPage { get; set; }
//تعداد کل صفحات
public long TotalPage { get; set; }
//تعداد در هر صفحه
public long PageSize { get; set; }
//تعداد کل آیتم‌ها
public long TotalCount { get; set; }
//قبلی دارد؟
public bool HasPrevious { get; set; }
//بعدی دارد؟
public bool HasNext { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace BackOffice.BFF.Application.Common.Models;
public class PaginationState
{
//شماره صفحه
public int PageNumber { get; set; }
//اندازه صفحه
public int PageSize { get; set; }
}

View File

@@ -0,0 +1,32 @@
using BackOffice.BFF.Application.Common.Behaviours;
using MapsterMapper;
using System.Reflection;
namespace Microsoft.Extensions.DependencyInjection;
public static class ConfigureServices
{
public static IServiceCollection AddApplicationServices(this IServiceCollection services)
{
services.AddMapping();
services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
services.AddMediatR(AppDomain.CurrentDomain.GetAssemblies());
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(UnhandledExceptionBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(PerformanceBehaviour<,>));
return services;
}
private static IServiceCollection AddMapping(this IServiceCollection services)
{
var typeAdapterConfig = TypeAdapterConfig.GlobalSettings;
// scans the assembly and gets the IRegister, adding the registration to the TypeAdapterConfig
typeAdapterConfig.Scan(Assembly.GetExecutingAssembly());
// register the mapper as Singleton service for my application
var mapperConfig = new Mapper(typeAdapterConfig);
services.AddSingleton<IMapper>(mapperConfig);
return services;
}
}

View File

@@ -0,0 +1,12 @@
global using MediatR;
global using FluentValidation;
global using Mapster;
global using System.Threading.Tasks;
global using System.Threading;
global using System.Collections.Generic;
global using System;
global using System.Linq;
global using Google.Protobuf.WellKnownTypes;
global using BackOffice.BFF.Application.Common.Interfaces;
global using BackOffice.BFF.Application.Common.Models;
global using BackOffice.BFF.Application.Common.Exceptions;

View File

@@ -0,0 +1,21 @@
namespace BackOffice.BFF.Application.PackageCQ.Commands.CreateNewPackage;
public record CreateNewPackageCommand : IRequest<CreateNewPackageResponseDto>
{
//عنوان
public string Title { get; init; }
//توضیحات
public string Description { get; init; }
//فایل تصویر
public BoostCardFileModel ImageFile { get; init; }
//قیمت
public long Price { get; init; }
}public class BoostCardFileModel
{
//فایل
public byte[] File { get; set; }
//نام
public string FileName { get; set; }
//نوع فایل
public string Mime { get; set; }
}

View File

@@ -0,0 +1,37 @@
using BackOffice.BFF.Application.UserCQ.Commands.CreateNewUser;
using CMSMicroservice.Protobuf.Protos.Package;
using Google.Protobuf;
namespace BackOffice.BFF.Application.PackageCQ.Commands.CreateNewPackage;
public class CreateNewPackageCommandHandler : IRequestHandler<CreateNewPackageCommand, CreateNewPackageResponseDto>
{
private readonly IApplicationContractContext _context;
public CreateNewPackageCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<CreateNewPackageResponseDto> Handle(CreateNewPackageCommand request, CancellationToken cancellationToken)
{
var createNewPackageRequest = request.Adapt<CreateNewPackageRequest>();
if (request.ImageFile != null && request.ImageFile.File != null && request.ImageFile.File.Length > 0)
{
var createNewFileInfo = await _context.FileInfos.CreateNewFileInfoAsync(new()
{
Directory = "Images/Package",
IsBase64 = false,
MIME = request.ImageFile.Mime,
FileName = request.ImageFile.FileName,
File = ByteString.CopyFrom(request.ImageFile.File)
}, cancellationToken: cancellationToken);
if (createNewFileInfo != null && !string.IsNullOrWhiteSpace(createNewFileInfo.File))
createNewPackageRequest.ImagePath = createNewFileInfo.File;
}
var response = await _context.Packages.CreateNewPackageAsync(createNewPackageRequest, cancellationToken: cancellationToken);
return response.Adapt<CreateNewPackageResponseDto>();
}
}

View File

@@ -0,0 +1,22 @@
namespace BackOffice.BFF.Application.PackageCQ.Commands.CreateNewPackage;
public class CreateNewPackageCommandValidator : AbstractValidator<CreateNewPackageCommand>
{
public CreateNewPackageCommandValidator()
{
RuleFor(model => model.Title)
.NotEmpty();
RuleFor(model => model.Description)
.NotEmpty();
RuleFor(model => model.ImageFile)
.NotNull();
RuleFor(model => model.Price)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<CreateNewPackageCommand>.CreateWithOptions((CreateNewPackageCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.PackageCQ.Commands.CreateNewPackage;
public class CreateNewPackageResponseDto
{
//شناسه
public long Id { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.PackageCQ.Commands.DeletePackage;
public record DeletePackageCommand : IRequest<Unit>
{
//شناسه
public long Id { get; init; }
}

View File

@@ -0,0 +1,19 @@
using CMSMicroservice.Protobuf.Protos.Package;
namespace BackOffice.BFF.Application.PackageCQ.Commands.DeletePackage;
public class DeletePackageCommandHandler : IRequestHandler<DeletePackageCommand, Unit>
{
private readonly IApplicationContractContext _context;
public DeletePackageCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(DeletePackageCommand request, CancellationToken cancellationToken)
{
await _context.Packages.DeletePackageAsync(request.Adapt<DeletePackageRequest>(), cancellationToken: cancellationToken);
return Unit.Value;
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.PackageCQ.Commands.DeletePackage;
public class DeletePackageCommandValidator : AbstractValidator<DeletePackageCommand>
{
public DeletePackageCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<DeletePackageCommand>.CreateWithOptions((DeletePackageCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,25 @@
namespace BackOffice.BFF.Application.PackageCQ.Commands.UpdatePackage;
public record UpdatePackageCommand : IRequest<Unit>
{
//شناسه
public long Id { get; init; }
//عنوان
public string Title { get; init; }
//توضیحات
public string Description { get; init; }
//آدرس تصویر
public string? ImagePath { get; init; }
//قیمت
public long Price { get; init; }
//فایل تصویر
public BoostCardFileModel? ImageFile { get; init; }
}public class BoostCardFileModel
{
//فایل
public byte[] File { get; set; }
//نام
public string FileName { get; set; }
//نوع فایل
public string Mime { get; set; }
}

View File

@@ -0,0 +1,35 @@
using CMSMicroservice.Protobuf.Protos.Package;
using Google.Protobuf;
namespace BackOffice.BFF.Application.PackageCQ.Commands.UpdatePackage;
public class UpdatePackageCommandHandler : IRequestHandler<UpdatePackageCommand, Unit>
{
private readonly IApplicationContractContext _context;
public UpdatePackageCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(UpdatePackageCommand request, CancellationToken cancellationToken)
{
var updatePackageRequest = request.Adapt<UpdatePackageRequest>();
if (request.ImageFile != null && request.ImageFile.File != null && request.ImageFile.File.Length > 0)
{
var createNewFileInfo = await _context.FileInfos.CreateNewFileInfoAsync(new()
{
Directory = "Images/Package",
IsBase64 = false,
MIME = request.ImageFile.Mime,
FileName = request.ImageFile.FileName,
File = ByteString.CopyFrom(request.ImageFile.File)
}, cancellationToken: cancellationToken);
if (createNewFileInfo != null && !string.IsNullOrWhiteSpace(createNewFileInfo.File))
updatePackageRequest.ImagePath = createNewFileInfo.File;
}
await _context.Packages.UpdatePackageAsync(updatePackageRequest, cancellationToken: cancellationToken);
return Unit.Value;
}
}

View File

@@ -0,0 +1,22 @@
namespace BackOffice.BFF.Application.PackageCQ.Commands.UpdatePackage;
public class UpdatePackageCommandValidator : AbstractValidator<UpdatePackageCommand>
{
public UpdatePackageCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
RuleFor(model => model.Title)
.NotEmpty();
RuleFor(model => model.Description)
.NotEmpty();
RuleFor(model => model.Price)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<UpdatePackageCommand>.CreateWithOptions((UpdatePackageCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,23 @@
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetAllPackageByFilter;
public record GetAllPackageByFilterQuery : IRequest<GetAllPackageByFilterResponseDto>
{
//موقعیت صفحه بندی
public PaginationState? PaginationState { get; init; }
//مرتب سازی بر اساس
public string? SortBy { get; init; }
//فیلتر
public GetAllPackageByFilterFilter? Filter { get; init; }
}public class GetAllPackageByFilterFilter
{
//شناسه
public long? Id { get; set; }
//عنوان
public string? Title { get; set; }
//توضیحات
public string? Description { get; set; }
//آدرس تصویر
public string? ImagePath { get; set; }
//قیمت
public long? Price { get; set; }
}

View File

@@ -0,0 +1,21 @@
using BackOffice.BFF.Application.UserCQ.Queries.GetAllUserByFilter;
using CMSMicroservice.Protobuf.Protos.Package;
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetAllPackageByFilter;
public class GetAllPackageByFilterQueryHandler : IRequestHandler<GetAllPackageByFilterQuery, GetAllPackageByFilterResponseDto>
{
private readonly IApplicationContractContext _context;
public GetAllPackageByFilterQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetAllPackageByFilterResponseDto> Handle(GetAllPackageByFilterQuery request, CancellationToken cancellationToken)
{
var response = await _context.Packages.GetAllPackageByFilterAsync(request.Adapt<GetAllPackageByFilterRequest>(), cancellationToken: cancellationToken);
return response.Adapt<GetAllPackageByFilterResponseDto>();
}
}

View File

@@ -0,0 +1,14 @@
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetAllPackageByFilter;
public class GetAllPackageByFilterQueryValidator : AbstractValidator<GetAllPackageByFilterQuery>
{
public GetAllPackageByFilterQueryValidator()
{
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetAllPackageByFilterQuery>.CreateWithOptions((GetAllPackageByFilterQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,21 @@
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetAllPackageByFilter;
public class GetAllPackageByFilterResponseDto
{
//متادیتا
public MetaData MetaData { get; set; }
//مدل خروجی
public List<GetAllPackageByFilterResponseModel>? Models { get; set; }
}public class GetAllPackageByFilterResponseModel
{
//شناسه
public long Id { get; set; }
//عنوان
public string Title { get; set; }
//توضیحات
public string Description { get; set; }
//آدرس تصویر
public string ImagePath { get; set; }
//قیمت
public long Price { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetPackage;
public record GetPackageQuery : IRequest<GetPackageResponseDto>
{
//شناسه
public long Id { get; init; }
}

View File

@@ -0,0 +1,20 @@
using BackOffice.BFF.Application.UserCQ.Queries.GetUser;
using CMSMicroservice.Protobuf.Protos.Package;
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetPackage;
public class GetPackageQueryHandler : IRequestHandler<GetPackageQuery, GetPackageResponseDto>
{
private readonly IApplicationContractContext _context;
public GetPackageQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetPackageResponseDto> Handle(GetPackageQuery request, CancellationToken cancellationToken)
{
var response = await _context.Packages.GetPackageAsync(request.Adapt<GetPackageRequest>(), cancellationToken: cancellationToken);
return response.Adapt<GetPackageResponseDto>();
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetPackage;
public class GetPackageQueryValidator : AbstractValidator<GetPackageQuery>
{
public GetPackageQueryValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetPackageQuery>.CreateWithOptions((GetPackageQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,15 @@
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetPackage;
public class GetPackageResponseDto
{
//شناسه
public long Id { get; set; }
//عنوان
public string Title { get; set; }
//توضیحات
public string Description { get; set; }
//آدرس تصویر
public string ImagePath { get; set; }
//قیمت
public long Price { get; set; }
}

View File

@@ -0,0 +1,9 @@
namespace BackOffice.BFF.Application.RoleCQ.Commands.CreateNewRole;
public record CreateNewRoleCommand : IRequest<CreateNewRoleResponseDto>
{
//نام لاتین
public string Name { get; init; }
//عنوان
public string Title { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.RoleCQ.Commands.CreateNewRole;
public class CreateNewRoleCommandHandler : IRequestHandler<CreateNewRoleCommand, CreateNewRoleResponseDto>
{
private readonly IApplicationContractContext _context;
public CreateNewRoleCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<CreateNewRoleResponseDto> Handle(CreateNewRoleCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new CreateNewRoleResponseDto();
}
}

View File

@@ -0,0 +1,18 @@
namespace BackOffice.BFF.Application.RoleCQ.Commands.CreateNewRole;
public class CreateNewRoleCommandValidator : AbstractValidator<CreateNewRoleCommand>
{
public CreateNewRoleCommandValidator()
{
RuleFor(model => model.Name)
.NotEmpty();
RuleFor(model => model.Title)
.NotEmpty();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<CreateNewRoleCommand>.CreateWithOptions((CreateNewRoleCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.RoleCQ.Commands.CreateNewRole;
public class CreateNewRoleResponseDto
{
//شناسه
public long Id { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.RoleCQ.Commands.DeleteRole;
public record DeleteRoleCommand : IRequest<Unit>
{
//شناسه
public long Id { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.RoleCQ.Commands.DeleteRole;
public class DeleteRoleCommandHandler : IRequestHandler<DeleteRoleCommand, Unit>
{
private readonly IApplicationContractContext _context;
public DeleteRoleCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(DeleteRoleCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new Unit();
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.RoleCQ.Commands.DeleteRole;
public class DeleteRoleCommandValidator : AbstractValidator<DeleteRoleCommand>
{
public DeleteRoleCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<DeleteRoleCommand>.CreateWithOptions((DeleteRoleCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,11 @@
namespace BackOffice.BFF.Application.RoleCQ.Commands.UpdateRole;
public record UpdateRoleCommand : IRequest<Unit>
{
//شناسه
public long Id { get; init; }
//نام لاتین
public string Name { get; init; }
//عنوان
public string Title { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.RoleCQ.Commands.UpdateRole;
public class UpdateRoleCommandHandler : IRequestHandler<UpdateRoleCommand, Unit>
{
private readonly IApplicationContractContext _context;
public UpdateRoleCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(UpdateRoleCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new Unit();
}
}

View File

@@ -0,0 +1,20 @@
namespace BackOffice.BFF.Application.RoleCQ.Commands.UpdateRole;
public class UpdateRoleCommandValidator : AbstractValidator<UpdateRoleCommand>
{
public UpdateRoleCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
RuleFor(model => model.Name)
.NotEmpty();
RuleFor(model => model.Title)
.NotEmpty();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<UpdateRoleCommand>.CreateWithOptions((UpdateRoleCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,19 @@
namespace BackOffice.BFF.Application.RoleCQ.Queries.GetAllRoleByFilter;
public record GetAllRoleByFilterQuery : IRequest<GetAllRoleByFilterResponseDto>
{
//موقعیت صفحه بندی
public PaginationState? PaginationState { get; init; }
//مرتب سازی بر اساس
public string? SortBy { get; init; }
//فیلتر
public GetAllRoleByFilterFilter? Filter { get; init; }
}public class GetAllRoleByFilterFilter
{
//شناسه
public long? Id { get; set; }
//نام لاتین
public string? Name { get; set; }
//عنوان
public string? Title { get; set; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.RoleCQ.Queries.GetAllRoleByFilter;
public class GetAllRoleByFilterQueryHandler : IRequestHandler<GetAllRoleByFilterQuery, GetAllRoleByFilterResponseDto>
{
private readonly IApplicationContractContext _context;
public GetAllRoleByFilterQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetAllRoleByFilterResponseDto> Handle(GetAllRoleByFilterQuery request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new GetAllRoleByFilterResponseDto();
}
}

View File

@@ -0,0 +1,14 @@
namespace BackOffice.BFF.Application.RoleCQ.Queries.GetAllRoleByFilter;
public class GetAllRoleByFilterQueryValidator : AbstractValidator<GetAllRoleByFilterQuery>
{
public GetAllRoleByFilterQueryValidator()
{
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetAllRoleByFilterQuery>.CreateWithOptions((GetAllRoleByFilterQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,17 @@
namespace BackOffice.BFF.Application.RoleCQ.Queries.GetAllRoleByFilter;
public class GetAllRoleByFilterResponseDto
{
//متادیتا
public MetaData MetaData { get; set; }
//مدل خروجی
public List<GetAllRoleByFilterResponseModel>? Models { get; set; }
}public class GetAllRoleByFilterResponseModel
{
//شناسه
public long Id { get; set; }
//نام لاتین
public string Name { get; set; }
//عنوان
public string Title { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.RoleCQ.Queries.GetRole;
public record GetRoleQuery : IRequest<GetRoleResponseDto>
{
//شناسه
public long Id { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.RoleCQ.Queries.GetRole;
public class GetRoleQueryHandler : IRequestHandler<GetRoleQuery, GetRoleResponseDto>
{
private readonly IApplicationContractContext _context;
public GetRoleQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetRoleResponseDto> Handle(GetRoleQuery request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new GetRoleResponseDto();
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.RoleCQ.Queries.GetRole;
public class GetRoleQueryValidator : AbstractValidator<GetRoleQuery>
{
public GetRoleQueryValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetRoleQuery>.CreateWithOptions((GetRoleQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,11 @@
namespace BackOffice.BFF.Application.RoleCQ.Queries.GetRole;
public class GetRoleResponseDto
{
//شناسه
public long Id { get; set; }
//نام لاتین
public string Name { get; set; }
//عنوان
public string Title { get; set; }
}

View File

@@ -0,0 +1,17 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.CreateNewUserAddress;
public record CreateNewUserAddressCommand : IRequest<CreateNewUserAddressResponseDto>
{
//شناسه کاربر
public long UserId { get; init; }
//عنوان
public string Title { get; init; }
//آدرس
public string Address { get; init; }
//کدپستی
public string PostalCode { get; init; }
//پیشفرض؟
public bool IsDefault { get; init; }
//شناسه شهر
public long CityId { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.CreateNewUserAddress;
public class CreateNewUserAddressCommandHandler : IRequestHandler<CreateNewUserAddressCommand, CreateNewUserAddressResponseDto>
{
private readonly IApplicationContractContext _context;
public CreateNewUserAddressCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<CreateNewUserAddressResponseDto> Handle(CreateNewUserAddressCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new CreateNewUserAddressResponseDto();
}
}

View File

@@ -0,0 +1,26 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.CreateNewUserAddress;
public class CreateNewUserAddressCommandValidator : AbstractValidator<CreateNewUserAddressCommand>
{
public CreateNewUserAddressCommandValidator()
{
RuleFor(model => model.UserId)
.NotNull();
RuleFor(model => model.Title)
.NotEmpty();
RuleFor(model => model.Address)
.NotEmpty();
RuleFor(model => model.PostalCode)
.NotEmpty();
RuleFor(model => model.IsDefault)
.NotNull();
RuleFor(model => model.CityId)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<CreateNewUserAddressCommand>.CreateWithOptions((CreateNewUserAddressCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.CreateNewUserAddress;
public class CreateNewUserAddressResponseDto
{
//شناسه
public long Id { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.DeleteUserAddress;
public record DeleteUserAddressCommand : IRequest<Unit>
{
//شناسه
public long Id { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.DeleteUserAddress;
public class DeleteUserAddressCommandHandler : IRequestHandler<DeleteUserAddressCommand, Unit>
{
private readonly IApplicationContractContext _context;
public DeleteUserAddressCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(DeleteUserAddressCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new Unit();
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.DeleteUserAddress;
public class DeleteUserAddressCommandValidator : AbstractValidator<DeleteUserAddressCommand>
{
public DeleteUserAddressCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<DeleteUserAddressCommand>.CreateWithOptions((DeleteUserAddressCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,19 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.UpdateUserAddress;
public record UpdateUserAddressCommand : IRequest<Unit>
{
//شناسه
public long Id { get; init; }
//شناسه کاربر
public long UserId { get; init; }
//عنوان
public string Title { get; init; }
//آدرس
public string Address { get; init; }
//کدپستی
public string PostalCode { get; init; }
//پیشفرض؟
public bool IsDefault { get; init; }
//شناسه شهر
public long CityId { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.UpdateUserAddress;
public class UpdateUserAddressCommandHandler : IRequestHandler<UpdateUserAddressCommand, Unit>
{
private readonly IApplicationContractContext _context;
public UpdateUserAddressCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(UpdateUserAddressCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new Unit();
}
}

View File

@@ -0,0 +1,28 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Commands.UpdateUserAddress;
public class UpdateUserAddressCommandValidator : AbstractValidator<UpdateUserAddressCommand>
{
public UpdateUserAddressCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
RuleFor(model => model.UserId)
.NotNull();
RuleFor(model => model.Title)
.NotEmpty();
RuleFor(model => model.Address)
.NotEmpty();
RuleFor(model => model.PostalCode)
.NotEmpty();
RuleFor(model => model.IsDefault)
.NotNull();
RuleFor(model => model.CityId)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<UpdateUserAddressCommand>.CreateWithOptions((UpdateUserAddressCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,27 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
public record GetAllUserAddressByFilterQuery : IRequest<GetAllUserAddressByFilterResponseDto>
{
//موقعیت صفحه بندی
public PaginationState? PaginationState { get; init; }
//مرتب سازی بر اساس
public string? SortBy { get; init; }
//فیلتر
public GetAllUserAddressByFilterFilter? Filter { get; init; }
}public class GetAllUserAddressByFilterFilter
{
//شناسه
public long? Id { get; set; }
//شناسه کاربر
public long? UserId { get; set; }
//عنوان
public string? Title { get; set; }
//آدرس
public string? Address { get; set; }
//کدپستی
public string? PostalCode { get; set; }
//پیشفرض؟
public bool? IsDefault { get; set; }
//شناسه شهر
public long? CityId { get; set; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
public class GetAllUserAddressByFilterQueryHandler : IRequestHandler<GetAllUserAddressByFilterQuery, GetAllUserAddressByFilterResponseDto>
{
private readonly IApplicationContractContext _context;
public GetAllUserAddressByFilterQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetAllUserAddressByFilterResponseDto> Handle(GetAllUserAddressByFilterQuery request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new GetAllUserAddressByFilterResponseDto();
}
}

View File

@@ -0,0 +1,14 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
public class GetAllUserAddressByFilterQueryValidator : AbstractValidator<GetAllUserAddressByFilterQuery>
{
public GetAllUserAddressByFilterQueryValidator()
{
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetAllUserAddressByFilterQuery>.CreateWithOptions((GetAllUserAddressByFilterQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,25 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
public class GetAllUserAddressByFilterResponseDto
{
//متادیتا
public MetaData MetaData { get; set; }
//مدل خروجی
public List<GetAllUserAddressByFilterResponseModel>? Models { get; set; }
}public class GetAllUserAddressByFilterResponseModel
{
//شناسه
public long Id { get; set; }
//شناسه کاربر
public long UserId { get; set; }
//عنوان
public string Title { get; set; }
//آدرس
public string Address { get; set; }
//کدپستی
public string PostalCode { get; set; }
//پیشفرض؟
public bool IsDefault { get; set; }
//شناسه شهر
public long CityId { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetUserAddress;
public record GetUserAddressQuery : IRequest<GetUserAddressResponseDto>
{
//شناسه
public long Id { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetUserAddress;
public class GetUserAddressQueryHandler : IRequestHandler<GetUserAddressQuery, GetUserAddressResponseDto>
{
private readonly IApplicationContractContext _context;
public GetUserAddressQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetUserAddressResponseDto> Handle(GetUserAddressQuery request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new GetUserAddressResponseDto();
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetUserAddress;
public class GetUserAddressQueryValidator : AbstractValidator<GetUserAddressQuery>
{
public GetUserAddressQueryValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetUserAddressQuery>.CreateWithOptions((GetUserAddressQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,19 @@
namespace BackOffice.BFF.Application.UserAddressCQ.Queries.GetUserAddress;
public class GetUserAddressResponseDto
{
//شناسه
public long Id { get; set; }
//شناسه کاربر
public long UserId { get; set; }
//عنوان
public string Title { get; set; }
//آدرس
public string Address { get; set; }
//کدپستی
public string PostalCode { get; set; }
//پیشفرض؟
public bool IsDefault { get; set; }
//شناسه شهر
public long CityId { get; set; }
}

View File

@@ -0,0 +1,17 @@
namespace BackOffice.BFF.Application.UserCQ.Commands.CreateNewUser;
public record CreateNewUserCommand : IRequest<CreateNewUserResponseDto>
{
//نام
public string? FirstName { get; init; }
//نام خانوادگی
public string? LastName { get; init; }
//شماره موبایل
public string Mobile { get; init; }
//کد ملی
public string? NationalCode { get; init; }
//آدرس آواتار
public string? AvatarPath { get; init; }
//شناسه والد
public long? ParentId { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserCQ.Commands.CreateNewUser;
public class CreateNewUserCommandHandler : IRequestHandler<CreateNewUserCommand, CreateNewUserResponseDto>
{
private readonly IApplicationContractContext _context;
public CreateNewUserCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<CreateNewUserResponseDto> Handle(CreateNewUserCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new CreateNewUserResponseDto();
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserCQ.Commands.CreateNewUser;
public class CreateNewUserCommandValidator : AbstractValidator<CreateNewUserCommand>
{
public CreateNewUserCommandValidator()
{
RuleFor(model => model.Mobile)
.NotEmpty();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<CreateNewUserCommand>.CreateWithOptions((CreateNewUserCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserCQ.Commands.CreateNewUser;
public class CreateNewUserResponseDto
{
//شناسه
public long Id { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserCQ.Commands.DeleteUser;
public record DeleteUserCommand : IRequest<Unit>
{
//شناسه
public long Id { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserCQ.Commands.DeleteUser;
public class DeleteUserCommandHandler : IRequestHandler<DeleteUserCommand, Unit>
{
private readonly IApplicationContractContext _context;
public DeleteUserCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(DeleteUserCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new Unit();
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserCQ.Commands.DeleteUser;
public class DeleteUserCommandValidator : AbstractValidator<DeleteUserCommand>
{
public DeleteUserCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<DeleteUserCommand>.CreateWithOptions((DeleteUserCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,19 @@
namespace BackOffice.BFF.Application.UserCQ.Commands.UpdateUser;
public record UpdateUserCommand : IRequest<Unit>
{
//شناسه
public long Id { get; init; }
//نام
public string? FirstName { get; init; }
//نام خانوادگی
public string? LastName { get; init; }
//شماره موبایل
public string Mobile { get; init; }
//کد ملی
public string? NationalCode { get; init; }
//آدرس آواتار
public string? AvatarPath { get; init; }
//شناسه والد
public long? ParentId { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserCQ.Commands.UpdateUser;
public class UpdateUserCommandHandler : IRequestHandler<UpdateUserCommand, Unit>
{
private readonly IApplicationContractContext _context;
public UpdateUserCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(UpdateUserCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new Unit();
}
}

View File

@@ -0,0 +1,18 @@
namespace BackOffice.BFF.Application.UserCQ.Commands.UpdateUser;
public class UpdateUserCommandValidator : AbstractValidator<UpdateUserCommand>
{
public UpdateUserCommandValidator()
{
RuleFor(model => model.Id)
.NotNull();
RuleFor(model => model.Mobile)
.NotEmpty();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<UpdateUserCommand>.CreateWithOptions((UpdateUserCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,27 @@
namespace BackOffice.BFF.Application.UserCQ.Queries.GetAllUserByFilter;
public record GetAllUserByFilterQuery : IRequest<GetAllUserByFilterResponseDto>
{
//موقعیت صفحه بندی
public PaginationState? PaginationState { get; init; }
//مرتب سازی بر اساس
public string? SortBy { get; init; }
//فیلتر
public GetAllUserByFilterFilter? Filter { get; init; }
}public class GetAllUserByFilterFilter
{
//شناسه
public long? Id { get; set; }
//نام
public string? FirstName { get; set; }
//نام خانوادگی
public string? LastName { get; set; }
//شماره موبایل
public string? Mobile { get; set; }
//کد ملی
public string? NationalCode { get; set; }
//آدرس آواتار
public string? AvatarPath { get; set; }
//شناسه والد
public long? ParentId { get; set; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserCQ.Queries.GetAllUserByFilter;
public class GetAllUserByFilterQueryHandler : IRequestHandler<GetAllUserByFilterQuery, GetAllUserByFilterResponseDto>
{
private readonly IApplicationContractContext _context;
public GetAllUserByFilterQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetAllUserByFilterResponseDto> Handle(GetAllUserByFilterQuery request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new GetAllUserByFilterResponseDto();
}
}

View File

@@ -0,0 +1,14 @@
namespace BackOffice.BFF.Application.UserCQ.Queries.GetAllUserByFilter;
public class GetAllUserByFilterQueryValidator : AbstractValidator<GetAllUserByFilterQuery>
{
public GetAllUserByFilterQueryValidator()
{
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetAllUserByFilterQuery>.CreateWithOptions((GetAllUserByFilterQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,25 @@
namespace BackOffice.BFF.Application.UserCQ.Queries.GetAllUserByFilter;
public class GetAllUserByFilterResponseDto
{
//متادیتا
public MetaData MetaData { get; set; }
//مدل خروجی
public List<GetAllUserByFilterResponseModel>? Models { get; set; }
}public class GetAllUserByFilterResponseModel
{
//شناسه
public long Id { get; set; }
//نام
public string? FirstName { get; set; }
//نام خانوادگی
public string? LastName { get; set; }
//شماره موبایل
public string Mobile { get; set; }
//کد ملی
public string? NationalCode { get; set; }
//آدرس آواتار
public string? AvatarPath { get; set; }
//شناسه والد
public long? ParentId { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserCQ.Queries.GetUser;
public record GetUserQuery : IRequest<GetUserResponseDto>
{
//شناسه
public long Id { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserCQ.Queries.GetUser;
public class GetUserQueryHandler : IRequestHandler<GetUserQuery, GetUserResponseDto>
{
private readonly IApplicationContractContext _context;
public GetUserQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetUserResponseDto> Handle(GetUserQuery request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new GetUserResponseDto();
}
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserCQ.Queries.GetUser;
public class GetUserQueryValidator : AbstractValidator<GetUserQuery>
{
public GetUserQueryValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetUserQuery>.CreateWithOptions((GetUserQuery)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,19 @@
namespace BackOffice.BFF.Application.UserCQ.Queries.GetUser;
public class GetUserResponseDto
{
//شناسه
public long Id { get; set; }
//نام
public string? FirstName { get; set; }
//نام خانوادگی
public string? LastName { get; set; }
//شماره موبایل
public string Mobile { get; set; }
//کد ملی
public string? NationalCode { get; set; }
//آدرس آواتار
public string? AvatarPath { get; set; }
//شناسه والد
public long? ParentId { get; set; }
}

View File

@@ -0,0 +1,17 @@
namespace BackOffice.BFF.Application.UserOrderCQ.Commands.CreateNewUserOrder;
public record CreateNewUserOrderCommand : IRequest<CreateNewUserOrderResponseDto>
{
//قیمت
public long Price { get; init; }
//شناسه پکیج
public long PackageId { get; init; }
//شناسه تراکنش
public long? TransactionId { get; init; }
//وضعیت پرداخت
public bool PaymentStatus { get; init; }
//تاریخ پرداخت
public DateTime? PaymentDate { get; init; }
//شناسه کاربر
public long UserId { get; init; }
}

View File

@@ -0,0 +1,16 @@
namespace BackOffice.BFF.Application.UserOrderCQ.Commands.CreateNewUserOrder;
public class CreateNewUserOrderCommandHandler : IRequestHandler<CreateNewUserOrderCommand, CreateNewUserOrderResponseDto>
{
private readonly IApplicationContractContext _context;
public CreateNewUserOrderCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<CreateNewUserOrderResponseDto> Handle(CreateNewUserOrderCommand request, CancellationToken cancellationToken)
{
//TODO: Implement your business logic
return new CreateNewUserOrderResponseDto();
}
}

View File

@@ -0,0 +1,22 @@
namespace BackOffice.BFF.Application.UserOrderCQ.Commands.CreateNewUserOrder;
public class CreateNewUserOrderCommandValidator : AbstractValidator<CreateNewUserOrderCommand>
{
public CreateNewUserOrderCommandValidator()
{
RuleFor(model => model.Price)
.NotNull();
RuleFor(model => model.PackageId)
.NotNull();
RuleFor(model => model.PaymentStatus)
.NotNull();
RuleFor(model => model.UserId)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<CreateNewUserOrderCommand>.CreateWithOptions((CreateNewUserOrderCommand)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.UserOrderCQ.Commands.CreateNewUserOrder;
public class CreateNewUserOrderResponseDto
{
//شناسه
public long Id { get; set; }
}

Some files were not shown because too many files have changed in this diff Show More