diff --git a/docs/model.ndm2 b/docs/model.ndm2 index af0a5a7..f19aeb0 100644 --- a/docs/model.ndm2 +++ b/docs/model.ndm2 @@ -6337,312 +6337,6 @@ "dataCompressions": [] } }, - { - "objectType": "Table_MSSQL", - "name": "CreateNewOtpTokenResponse", - "comment": "خروجی ایجاد توکن Otp جدید", - "owner": "", - "isChangeTracking": false, - "isTrackColumnsUpdated": false, - "oldName": "", - "isSystemTable": false, - "createTime": "", - "modifyTime": "", - "objectID": 8040, - "numberOfRows": 0, - "identityCurrent": 0, - "dataLength": 0, - "indexLength": 0, - "fields": [ - { - "objectType": "TableField_MSSQL", - "name": "Success", - "type": "bit", - "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": "Success", - "computedBaseType": "", - "isDefaultConstraint": false, - "defaultConstraint": "", - "isIdentity": false, - "isExistingField": false, - "identitySeed": 0, - "identityIncrement": 0, - "identityIsNotForReplication": false - }, - { - "objectType": "TableField_MSSQL", - "name": "Message", - "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": "Message", - "computedBaseType": "", - "isDefaultConstraint": false, - "defaultConstraint": "", - "isIdentity": false, - "isExistingField": false, - "identitySeed": 0, - "identityIncrement": 0, - "identityIsNotForReplication": false - }, - { - "objectType": "TableField_MSSQL", - "name": "Code", - "type": "nvarchar", - "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": "Code", - "computedBaseType": "", - "isDefaultConstraint": false, - "defaultConstraint": "", - "isIdentity": false, - "isExistingField": false, - "identitySeed": 0, - "identityIncrement": 0, - "identityIsNotForReplication": false - } - ], - "indexes": [], - "primaryKey": { - "objectType": "PrimaryKey_MSSQL", - "name": "_copy_47", - "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": "VerifyOtpTokenResponse", - "comment": "خروجی فعال‌سازی توکن Otp", - "owner": "", - "isChangeTracking": false, - "isTrackColumnsUpdated": false, - "oldName": "", - "isSystemTable": false, - "createTime": "", - "modifyTime": "", - "objectID": 8040, - "numberOfRows": 0, - "identityCurrent": 0, - "dataLength": 0, - "indexLength": 0, - "fields": [ - { - "objectType": "TableField_MSSQL", - "name": "Success", - "type": "bit", - "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": "Success", - "computedBaseType": "", - "isDefaultConstraint": false, - "defaultConstraint": "", - "isIdentity": false, - "isExistingField": false, - "identitySeed": 0, - "identityIncrement": 0, - "identityIsNotForReplication": false - }, - { - "objectType": "TableField_MSSQL", - "name": "Message", - "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": "Message", - "computedBaseType": "", - "isDefaultConstraint": false, - "defaultConstraint": "", - "isIdentity": false, - "isExistingField": false, - "identitySeed": 0, - "identityIncrement": 0, - "identityIsNotForReplication": false - }, - { - "objectType": "TableField_MSSQL", - "name": "UserId", - "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": "UserId", - "computedBaseType": "", - "isDefaultConstraint": false, - "defaultConstraint": "", - "isIdentity": false, - "isExistingField": false, - "identitySeed": 0, - "identityIncrement": 0, - "identityIsNotForReplication": false - } - ], - "indexes": [], - "primaryKey": { - "objectType": "PrimaryKey_MSSQL", - "name": "_copy_47_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": "CreateNewOtpTokenRequest", @@ -8558,6 +8252,282 @@ "filestreamPartitionScheme": "", "dataCompressions": [] } + }, + { + "objectType": "Table_MSSQL", + "name": "CreateNewOtpTokenResponse", + "comment": "خروجی ایجاد توکن Otp جدید", + "owner": "", + "isChangeTracking": false, + "isTrackColumnsUpdated": false, + "oldName": "", + "isSystemTable": false, + "createTime": "", + "modifyTime": "", + "objectID": 8040, + "numberOfRows": 0, + "identityCurrent": 0, + "dataLength": 0, + "indexLength": 0, + "fields": [ + { + "objectType": "TableField_MSSQL", + "name": "Success", + "type": "bit", + "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": "Success", + "computedBaseType": "", + "isDefaultConstraint": false, + "defaultConstraint": "", + "isIdentity": false, + "isExistingField": false, + "identitySeed": 0, + "identityIncrement": 0, + "identityIsNotForReplication": false + }, + { + "objectType": "TableField_MSSQL", + "name": "Message", + "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": "Message", + "computedBaseType": "", + "isDefaultConstraint": false, + "defaultConstraint": "", + "isIdentity": false, + "isExistingField": false, + "identitySeed": 0, + "identityIncrement": 0, + "identityIsNotForReplication": false + } + ], + "indexes": [], + "primaryKey": { + "objectType": "PrimaryKey_MSSQL", + "name": "_copy_47", + "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": "VerifyOtpTokenResponse", + "comment": "خروجی فعال‌سازی توکن Otp", + "owner": "", + "isChangeTracking": false, + "isTrackColumnsUpdated": false, + "oldName": "", + "isSystemTable": false, + "createTime": "", + "modifyTime": "", + "objectID": 8040, + "numberOfRows": 0, + "identityCurrent": 0, + "dataLength": 0, + "indexLength": 0, + "fields": [ + { + "objectType": "TableField_MSSQL", + "name": "Success", + "type": "bit", + "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": "Success", + "computedBaseType": "", + "isDefaultConstraint": false, + "defaultConstraint": "", + "isIdentity": false, + "isExistingField": false, + "identitySeed": 0, + "identityIncrement": 0, + "identityIsNotForReplication": false + }, + { + "objectType": "TableField_MSSQL", + "name": "Message", + "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": "Message", + "computedBaseType": "", + "isDefaultConstraint": false, + "defaultConstraint": "", + "isIdentity": false, + "isExistingField": false, + "identitySeed": 0, + "identityIncrement": 0, + "identityIsNotForReplication": false + }, + { + "objectType": "TableField_MSSQL", + "name": "Token", + "type": "nvarchar", + "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": "Token", + "computedBaseType": "", + "isDefaultConstraint": false, + "defaultConstraint": "", + "isIdentity": false, + "isExistingField": false, + "identitySeed": 0, + "identityIncrement": 0, + "identityIsNotForReplication": false + } + ], + "indexes": [], + "primaryKey": { + "objectType": "PrimaryKey_MSSQL", + "name": "_copy_47_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": [] diff --git a/src/FrontOffice.BFF.Application/Common/Interfaces/IApplicationContractContext.cs b/src/FrontOffice.BFF.Application/Common/Interfaces/IApplicationContractContext.cs index 235732f..70b3027 100644 --- a/src/FrontOffice.BFF.Application/Common/Interfaces/IApplicationContractContext.cs +++ b/src/FrontOffice.BFF.Application/Common/Interfaces/IApplicationContractContext.cs @@ -1,3 +1,9 @@ +using CMSMicroservice.Protobuf.Protos.OtpToken; +using CMSMicroservice.Protobuf.Protos.Package; +using CMSMicroservice.Protobuf.Protos.User; +using CMSMicroservice.Protobuf.Protos.UserAddress; +using CMSMicroservice.Protobuf.Protos.UserOrder; + namespace FrontOffice.BFF.Application.Common.Interfaces; public interface IApplicationContractContext @@ -7,4 +13,12 @@ public interface IApplicationContractContext //FileLogContract.FileLogContractClient FileManagements { get; } #endregion + + #region CMS + PackageContract.PackageContractClient Package { get; } + UserContract.UserContractClient User { get; } + UserAddressContract.UserAddressContractClient UserAddress { get; } + UserOrderContract.UserOrderContractClient UserOrder { get; } + OtpTokenContract.OtpTokenContractClient OtpToken { get; } + #endregion } diff --git a/src/FrontOffice.BFF.Application/Common/Interfaces/IKavenegarService.cs b/src/FrontOffice.BFF.Application/Common/Interfaces/IKavenegarService.cs new file mode 100644 index 0000000..d8c0667 --- /dev/null +++ b/src/FrontOffice.BFF.Application/Common/Interfaces/IKavenegarService.cs @@ -0,0 +1,6 @@ +namespace FrontOffice.BFF.Application.Common.Interfaces; +public interface IKavenegarService +{ + Task Send(string mobile, string message); + Task VerifyLookup(string mobile, string token); +} diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageCommand.cs b/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageCommand.cs deleted file mode 100644 index 4a291ae..0000000 --- a/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageCommand.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace FrontOffice.BFF.Application.PackageCQ.Commands.CreateNewPackage; -public record CreateNewPackageCommand : IRequest -{ - //عنوان - public string Title { get; init; } - //توضیحات - public string Description { get; init; } - //آدرس تصویر - public string ImagePath { get; init; } - //قیمت - public long Price { get; init; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageCommandHandler.cs b/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageCommandHandler.cs deleted file mode 100644 index 57f39f6..0000000 --- a/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageCommandHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.PackageCQ.Commands.CreateNewPackage; -public class CreateNewPackageCommandHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public CreateNewPackageCommandHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(CreateNewPackageCommand request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new CreateNewPackageResponseDto(); - } -} diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageCommandValidator.cs b/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageCommandValidator.cs deleted file mode 100644 index eb52a00..0000000 --- a/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageCommandValidator.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace FrontOffice.BFF.Application.PackageCQ.Commands.CreateNewPackage; -public class CreateNewPackageCommandValidator : AbstractValidator -{ - public CreateNewPackageCommandValidator() - { - RuleFor(model => model.Title) - .NotEmpty(); - RuleFor(model => model.Description) - .NotEmpty(); - RuleFor(model => model.ImagePath) - .NotEmpty(); - RuleFor(model => model.Price) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewPackageCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageResponseDto.cs b/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageResponseDto.cs deleted file mode 100644 index 64cb57d..0000000 --- a/src/FrontOffice.BFF.Application/PackageCQ/Commands/CreateNewPackage/CreateNewPackageResponseDto.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FrontOffice.BFF.Application.PackageCQ.Commands.CreateNewPackage; -public class CreateNewPackageResponseDto -{ - //شناسه - public long Id { get; set; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Commands/DeletePackage/DeletePackageCommand.cs b/src/FrontOffice.BFF.Application/PackageCQ/Commands/DeletePackage/DeletePackageCommand.cs deleted file mode 100644 index 6ed2fcb..0000000 --- a/src/FrontOffice.BFF.Application/PackageCQ/Commands/DeletePackage/DeletePackageCommand.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FrontOffice.BFF.Application.PackageCQ.Commands.DeletePackage; -public record DeletePackageCommand : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Commands/DeletePackage/DeletePackageCommandHandler.cs b/src/FrontOffice.BFF.Application/PackageCQ/Commands/DeletePackage/DeletePackageCommandHandler.cs deleted file mode 100644 index f581411..0000000 --- a/src/FrontOffice.BFF.Application/PackageCQ/Commands/DeletePackage/DeletePackageCommandHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.PackageCQ.Commands.DeletePackage; -public class DeletePackageCommandHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public DeletePackageCommandHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(DeletePackageCommand request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new Unit(); - } -} diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Commands/DeletePackage/DeletePackageCommandValidator.cs b/src/FrontOffice.BFF.Application/PackageCQ/Commands/DeletePackage/DeletePackageCommandValidator.cs deleted file mode 100644 index dc3aa95..0000000 --- a/src/FrontOffice.BFF.Application/PackageCQ/Commands/DeletePackage/DeletePackageCommandValidator.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.PackageCQ.Commands.DeletePackage; -public class DeletePackageCommandValidator : AbstractValidator -{ - public DeletePackageCommandValidator() - { - RuleFor(model => model.Id) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeletePackageCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Commands/UpdatePackage/UpdatePackageCommand.cs b/src/FrontOffice.BFF.Application/PackageCQ/Commands/UpdatePackage/UpdatePackageCommand.cs deleted file mode 100644 index 151a4af..0000000 --- a/src/FrontOffice.BFF.Application/PackageCQ/Commands/UpdatePackage/UpdatePackageCommand.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace FrontOffice.BFF.Application.PackageCQ.Commands.UpdatePackage; -public record UpdatePackageCommand : IRequest -{ - //شناسه - 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; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Commands/UpdatePackage/UpdatePackageCommandHandler.cs b/src/FrontOffice.BFF.Application/PackageCQ/Commands/UpdatePackage/UpdatePackageCommandHandler.cs deleted file mode 100644 index 5c73caa..0000000 --- a/src/FrontOffice.BFF.Application/PackageCQ/Commands/UpdatePackage/UpdatePackageCommandHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.PackageCQ.Commands.UpdatePackage; -public class UpdatePackageCommandHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public UpdatePackageCommandHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(UpdatePackageCommand request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new Unit(); - } -} diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Commands/UpdatePackage/UpdatePackageCommandValidator.cs b/src/FrontOffice.BFF.Application/PackageCQ/Commands/UpdatePackage/UpdatePackageCommandValidator.cs deleted file mode 100644 index 7ab1ac3..0000000 --- a/src/FrontOffice.BFF.Application/PackageCQ/Commands/UpdatePackage/UpdatePackageCommandValidator.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace FrontOffice.BFF.Application.PackageCQ.Commands.UpdatePackage; -public class UpdatePackageCommandValidator : AbstractValidator -{ - public UpdatePackageCommandValidator() - { - RuleFor(model => model.Id) - .NotNull(); - RuleFor(model => model.Title) - .NotEmpty(); - RuleFor(model => model.Description) - .NotEmpty(); - RuleFor(model => model.ImagePath) - .NotEmpty(); - RuleFor(model => model.Price) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdatePackageCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Queries/GetAllPackageByFilter/GetAllPackageByFilterQueryHandler.cs b/src/FrontOffice.BFF.Application/PackageCQ/Queries/GetAllPackageByFilter/GetAllPackageByFilterQueryHandler.cs index 955ec5c..edb7282 100644 --- a/src/FrontOffice.BFF.Application/PackageCQ/Queries/GetAllPackageByFilter/GetAllPackageByFilterQueryHandler.cs +++ b/src/FrontOffice.BFF.Application/PackageCQ/Queries/GetAllPackageByFilter/GetAllPackageByFilterQueryHandler.cs @@ -1,3 +1,5 @@ +using CMSMicroservice.Protobuf.Protos.Package; + namespace FrontOffice.BFF.Application.PackageCQ.Queries.GetAllPackageByFilter; public class GetAllPackageByFilterQueryHandler : IRequestHandler { @@ -10,7 +12,7 @@ public class GetAllPackageByFilterQueryHandler : IRequestHandler Handle(GetAllPackageByFilterQuery request, CancellationToken cancellationToken) { - //TODO: Implement your business logic - return new GetAllPackageByFilterResponseDto(); + var response = await _context.Package.GetAllPackageByFilterAsync(request: request.Adapt(), cancellationToken: cancellationToken); + return response.Adapt(); } } diff --git a/src/FrontOffice.BFF.Application/PackageCQ/Queries/GetPackage/GetPackageQueryHandler.cs b/src/FrontOffice.BFF.Application/PackageCQ/Queries/GetPackage/GetPackageQueryHandler.cs index 7a2f6b3..2b77d18 100644 --- a/src/FrontOffice.BFF.Application/PackageCQ/Queries/GetPackage/GetPackageQueryHandler.cs +++ b/src/FrontOffice.BFF.Application/PackageCQ/Queries/GetPackage/GetPackageQueryHandler.cs @@ -1,3 +1,5 @@ +using CMSMicroservice.Protobuf.Protos.Package; + namespace FrontOffice.BFF.Application.PackageCQ.Queries.GetPackage; public class GetPackageQueryHandler : IRequestHandler { @@ -10,7 +12,7 @@ public class GetPackageQueryHandler : IRequestHandler Handle(GetPackageQuery request, CancellationToken cancellationToken) { - //TODO: Implement your business logic - return new GetPackageResponseDto(); + var response = await _context.Package.GetPackageAsync(request: request.Adapt(), cancellationToken: cancellationToken); + return response.Adapt(); } } diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleCommand.cs b/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleCommand.cs deleted file mode 100644 index 4487dbe..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleCommand.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Commands.CreateNewRole; -public record CreateNewRoleCommand : IRequest -{ - //نام لاتین - public string Name { get; init; } - //عنوان - public string Title { get; init; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleCommandHandler.cs b/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleCommandHandler.cs deleted file mode 100644 index 7e1bd4f..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleCommandHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Commands.CreateNewRole; -public class CreateNewRoleCommandHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public CreateNewRoleCommandHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(CreateNewRoleCommand request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new CreateNewRoleResponseDto(); - } -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleCommandValidator.cs b/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleCommandValidator.cs deleted file mode 100644 index 6efb675..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleCommandValidator.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Commands.CreateNewRole; -public class CreateNewRoleCommandValidator : AbstractValidator -{ - public CreateNewRoleCommandValidator() - { - RuleFor(model => model.Name) - .NotEmpty(); - RuleFor(model => model.Title) - .NotEmpty(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewRoleCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleResponseDto.cs b/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleResponseDto.cs deleted file mode 100644 index 64e4bb3..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Commands/CreateNewRole/CreateNewRoleResponseDto.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Commands.CreateNewRole; -public class CreateNewRoleResponseDto -{ - //شناسه - public long Id { get; set; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Commands/DeleteRole/DeleteRoleCommand.cs b/src/FrontOffice.BFF.Application/RoleCQ/Commands/DeleteRole/DeleteRoleCommand.cs deleted file mode 100644 index 6eda120..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Commands/DeleteRole/DeleteRoleCommand.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Commands.DeleteRole; -public record DeleteRoleCommand : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Commands/DeleteRole/DeleteRoleCommandHandler.cs b/src/FrontOffice.BFF.Application/RoleCQ/Commands/DeleteRole/DeleteRoleCommandHandler.cs deleted file mode 100644 index d0bcbdf..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Commands/DeleteRole/DeleteRoleCommandHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Commands.DeleteRole; -public class DeleteRoleCommandHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public DeleteRoleCommandHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(DeleteRoleCommand request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new Unit(); - } -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Commands/DeleteRole/DeleteRoleCommandValidator.cs b/src/FrontOffice.BFF.Application/RoleCQ/Commands/DeleteRole/DeleteRoleCommandValidator.cs deleted file mode 100644 index 6db61f2..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Commands/DeleteRole/DeleteRoleCommandValidator.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Commands.DeleteRole; -public class DeleteRoleCommandValidator : AbstractValidator -{ - public DeleteRoleCommandValidator() - { - RuleFor(model => model.Id) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteRoleCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Commands/UpdateRole/UpdateRoleCommand.cs b/src/FrontOffice.BFF.Application/RoleCQ/Commands/UpdateRole/UpdateRoleCommand.cs deleted file mode 100644 index ca8a8ac..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Commands/UpdateRole/UpdateRoleCommand.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Commands.UpdateRole; -public record UpdateRoleCommand : IRequest -{ - //شناسه - public long Id { get; init; } - //نام لاتین - public string Name { get; init; } - //عنوان - public string Title { get; init; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Commands/UpdateRole/UpdateRoleCommandHandler.cs b/src/FrontOffice.BFF.Application/RoleCQ/Commands/UpdateRole/UpdateRoleCommandHandler.cs deleted file mode 100644 index 631b37e..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Commands/UpdateRole/UpdateRoleCommandHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Commands.UpdateRole; -public class UpdateRoleCommandHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public UpdateRoleCommandHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(UpdateRoleCommand request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new Unit(); - } -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Commands/UpdateRole/UpdateRoleCommandValidator.cs b/src/FrontOffice.BFF.Application/RoleCQ/Commands/UpdateRole/UpdateRoleCommandValidator.cs deleted file mode 100644 index 2bffcaf..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Commands/UpdateRole/UpdateRoleCommandValidator.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Commands.UpdateRole; -public class UpdateRoleCommandValidator : AbstractValidator -{ - public UpdateRoleCommandValidator() - { - RuleFor(model => model.Id) - .NotNull(); - RuleFor(model => model.Name) - .NotEmpty(); - RuleFor(model => model.Title) - .NotEmpty(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateRoleCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterQuery.cs b/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterQuery.cs deleted file mode 100644 index 7081e8a..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterQuery.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Queries.GetAllRoleByFilter; -public record GetAllRoleByFilterQuery : IRequest -{ - //موقعیت صفحه بندی - 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; } -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterQueryHandler.cs b/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterQueryHandler.cs deleted file mode 100644 index aa83ea7..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterQueryHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Queries.GetAllRoleByFilter; -public class GetAllRoleByFilterQueryHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public GetAllRoleByFilterQueryHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(GetAllRoleByFilterQuery request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new GetAllRoleByFilterResponseDto(); - } -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterQueryValidator.cs b/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterQueryValidator.cs deleted file mode 100644 index e960deb..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterQueryValidator.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Queries.GetAllRoleByFilter; -public class GetAllRoleByFilterQueryValidator : AbstractValidator -{ - public GetAllRoleByFilterQueryValidator() - { - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllRoleByFilterQuery)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterResponseDto.cs b/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterResponseDto.cs deleted file mode 100644 index 25526bf..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetAllRoleByFilter/GetAllRoleByFilterResponseDto.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Queries.GetAllRoleByFilter; -public class GetAllRoleByFilterResponseDto -{ - //متادیتا - public MetaData MetaData { get; set; } - //مدل خروجی - public List? Models { get; set; } - -}public class GetAllRoleByFilterResponseModel -{ - //شناسه - public long Id { get; set; } - //نام لاتین - public string Name { get; set; } - //عنوان - public string Title { get; set; } -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleQuery.cs b/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleQuery.cs deleted file mode 100644 index a4959a7..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleQuery.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Queries.GetRole; -public record GetRoleQuery : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleQueryHandler.cs b/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleQueryHandler.cs deleted file mode 100644 index d3aca8c..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleQueryHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Queries.GetRole; -public class GetRoleQueryHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public GetRoleQueryHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(GetRoleQuery request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new GetRoleResponseDto(); - } -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleQueryValidator.cs b/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleQueryValidator.cs deleted file mode 100644 index e472475..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleQueryValidator.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Queries.GetRole; -public class GetRoleQueryValidator : AbstractValidator -{ - public GetRoleQueryValidator() - { - RuleFor(model => model.Id) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetRoleQuery)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleResponseDto.cs b/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleResponseDto.cs deleted file mode 100644 index 1d949cb..0000000 --- a/src/FrontOffice.BFF.Application/RoleCQ/Queries/GetRole/GetRoleResponseDto.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace FrontOffice.BFF.Application.RoleCQ.Queries.GetRole; -public class GetRoleResponseDto -{ - //شناسه - public long Id { get; set; } - //نام لاتین - public string Name { get; set; } - //عنوان - public string Title { get; set; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewOtpToken/CreateNewOtpTokenCommandHandler.cs b/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewOtpToken/CreateNewOtpTokenCommandHandler.cs index d9acd8f..e5d7547 100644 --- a/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewOtpToken/CreateNewOtpTokenCommandHandler.cs +++ b/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewOtpToken/CreateNewOtpTokenCommandHandler.cs @@ -1,16 +1,22 @@ +using CMSMicroservice.Protobuf.Protos.OtpToken; + namespace FrontOffice.BFF.Application.UserCQ.Commands.CreateNewOtpToken; public class CreateNewOtpTokenCommandHandler : IRequestHandler { private readonly IApplicationContractContext _context; + private readonly IKavenegarService _kavenegarService; - public CreateNewOtpTokenCommandHandler(IApplicationContractContext context) + public CreateNewOtpTokenCommandHandler(IApplicationContractContext context, IKavenegarService kavenegarService) { _context = context; + _kavenegarService = kavenegarService; } public async Task Handle(CreateNewOtpTokenCommand request, CancellationToken cancellationToken) { - //TODO: Implement your business logic - return new CreateNewOtpTokenResponseDto(); + var response = await _context.OtpToken.CreateNewOtpTokenAsync(request: request.Adapt(), cancellationToken: cancellationToken); + if (response.Success && !string.IsNullOrWhiteSpace(response.Code)) + await _kavenegarService.VerifyLookup(mobile: request.Mobile, response.Code); + return response.Adapt(); } } diff --git a/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserCommand.cs b/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserCommand.cs deleted file mode 100644 index ac2d13b..0000000 --- a/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserCommand.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace FrontOffice.BFF.Application.UserCQ.Commands.CreateNewUser; -public record CreateNewUserCommand : IRequest -{ - //نام - 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; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserCommandHandler.cs b/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserCommandHandler.cs deleted file mode 100644 index fc81c98..0000000 --- a/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserCommandHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.UserCQ.Commands.CreateNewUser; -public class CreateNewUserCommandHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public CreateNewUserCommandHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(CreateNewUserCommand request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new CreateNewUserResponseDto(); - } -} diff --git a/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserCommandValidator.cs b/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserCommandValidator.cs deleted file mode 100644 index f2ab0c8..0000000 --- a/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserCommandValidator.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.UserCQ.Commands.CreateNewUser; -public class CreateNewUserCommandValidator : AbstractValidator -{ - public CreateNewUserCommandValidator() - { - RuleFor(model => model.Mobile) - .NotEmpty(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewUserCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserResponseDto.cs b/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserResponseDto.cs deleted file mode 100644 index 8a91aa1..0000000 --- a/src/FrontOffice.BFF.Application/UserCQ/Commands/CreateNewUser/CreateNewUserResponseDto.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FrontOffice.BFF.Application.UserCQ.Commands.CreateNewUser; -public class CreateNewUserResponseDto -{ - //شناسه - public long Id { get; set; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleCommand.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleCommand.cs deleted file mode 100644 index 9ae5c60..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleCommand.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Commands.CreateNewUserRole; -public record CreateNewUserRoleCommand : IRequest -{ - //شناسه نقش - public long RoleId { get; init; } - //شناسه کاربر - public long UserId { get; init; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleCommandHandler.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleCommandHandler.cs deleted file mode 100644 index efe2afc..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleCommandHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Commands.CreateNewUserRole; -public class CreateNewUserRoleCommandHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public CreateNewUserRoleCommandHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(CreateNewUserRoleCommand request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new CreateNewUserRoleResponseDto(); - } -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleCommandValidator.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleCommandValidator.cs deleted file mode 100644 index f061946..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleCommandValidator.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Commands.CreateNewUserRole; -public class CreateNewUserRoleCommandValidator : AbstractValidator -{ - public CreateNewUserRoleCommandValidator() - { - RuleFor(model => model.RoleId) - .NotNull(); - RuleFor(model => model.UserId) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewUserRoleCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleResponseDto.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleResponseDto.cs deleted file mode 100644 index a39888d..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/CreateNewUserRole/CreateNewUserRoleResponseDto.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Commands.CreateNewUserRole; -public class CreateNewUserRoleResponseDto -{ - //شناسه - public long Id { get; set; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/DeleteUserRole/DeleteUserRoleCommand.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/DeleteUserRole/DeleteUserRoleCommand.cs deleted file mode 100644 index 8850934..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/DeleteUserRole/DeleteUserRoleCommand.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Commands.DeleteUserRole; -public record DeleteUserRoleCommand : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/DeleteUserRole/DeleteUserRoleCommandHandler.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/DeleteUserRole/DeleteUserRoleCommandHandler.cs deleted file mode 100644 index 974cb92..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/DeleteUserRole/DeleteUserRoleCommandHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Commands.DeleteUserRole; -public class DeleteUserRoleCommandHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public DeleteUserRoleCommandHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(DeleteUserRoleCommand request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new Unit(); - } -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/DeleteUserRole/DeleteUserRoleCommandValidator.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/DeleteUserRole/DeleteUserRoleCommandValidator.cs deleted file mode 100644 index 94ba9af..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/DeleteUserRole/DeleteUserRoleCommandValidator.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Commands.DeleteUserRole; -public class DeleteUserRoleCommandValidator : AbstractValidator -{ - public DeleteUserRoleCommandValidator() - { - RuleFor(model => model.Id) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeleteUserRoleCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/UpdateUserRole/UpdateUserRoleCommand.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/UpdateUserRole/UpdateUserRoleCommand.cs deleted file mode 100644 index 341dd11..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/UpdateUserRole/UpdateUserRoleCommand.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Commands.UpdateUserRole; -public record UpdateUserRoleCommand : IRequest -{ - //شناسه - public long Id { get; init; } - //شناسه نقش - public long RoleId { get; init; } - //شناسه کاربر - public long UserId { get; init; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/UpdateUserRole/UpdateUserRoleCommandHandler.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/UpdateUserRole/UpdateUserRoleCommandHandler.cs deleted file mode 100644 index b35dbaa..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/UpdateUserRole/UpdateUserRoleCommandHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Commands.UpdateUserRole; -public class UpdateUserRoleCommandHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public UpdateUserRoleCommandHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(UpdateUserRoleCommand request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new Unit(); - } -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/UpdateUserRole/UpdateUserRoleCommandValidator.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/UpdateUserRole/UpdateUserRoleCommandValidator.cs deleted file mode 100644 index bb316a5..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Commands/UpdateUserRole/UpdateUserRoleCommandValidator.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Commands.UpdateUserRole; -public class UpdateUserRoleCommandValidator : AbstractValidator -{ - public UpdateUserRoleCommandValidator() - { - RuleFor(model => model.Id) - .NotNull(); - RuleFor(model => model.RoleId) - .NotNull(); - RuleFor(model => model.UserId) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdateUserRoleCommand)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterQuery.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterQuery.cs deleted file mode 100644 index bb5673e..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterQuery.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter; -public record GetAllUserRoleByFilterQuery : IRequest -{ - //موقعیت صفحه بندی - public PaginationState? PaginationState { get; init; } - //مرتب سازی بر اساس - public string? SortBy { get; init; } - //فیلتر - public GetAllUserRoleByFilterFilter? Filter { get; init; } - -}public class GetAllUserRoleByFilterFilter -{ - //شناسه - public long? Id { get; set; } - //شناسه نقش - public long? RoleId { get; set; } - //شناسه کاربر - public long? UserId { get; set; } -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterQueryHandler.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterQueryHandler.cs deleted file mode 100644 index 42eb473..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterQueryHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter; -public class GetAllUserRoleByFilterQueryHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public GetAllUserRoleByFilterQueryHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(GetAllUserRoleByFilterQuery request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new GetAllUserRoleByFilterResponseDto(); - } -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterQueryValidator.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterQueryValidator.cs deleted file mode 100644 index 6b5ba03..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterQueryValidator.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter; -public class GetAllUserRoleByFilterQueryValidator : AbstractValidator -{ - public GetAllUserRoleByFilterQueryValidator() - { - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetAllUserRoleByFilterQuery)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterResponseDto.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterResponseDto.cs deleted file mode 100644 index c0fe4a4..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetAllUserRoleByFilter/GetAllUserRoleByFilterResponseDto.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter; -public class GetAllUserRoleByFilterResponseDto -{ - //متادیتا - public MetaData MetaData { get; set; } - //مدل خروجی - public List? Models { get; set; } - -}public class GetAllUserRoleByFilterResponseModel -{ - //شناسه - public long Id { get; set; } - //شناسه نقش - public long RoleId { get; set; } - //شناسه کاربر - public long UserId { get; set; } -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleQuery.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleQuery.cs deleted file mode 100644 index 8c52541..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleQuery.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Queries.GetUserRole; -public record GetUserRoleQuery : IRequest -{ - //شناسه - public long Id { get; init; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleQueryHandler.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleQueryHandler.cs deleted file mode 100644 index 36ae41b..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleQueryHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Queries.GetUserRole; -public class GetUserRoleQueryHandler : IRequestHandler -{ - private readonly IApplicationContractContext _context; - - public GetUserRoleQueryHandler(IApplicationContractContext context) - { - _context = context; - } - - public async Task Handle(GetUserRoleQuery request, CancellationToken cancellationToken) - { - //TODO: Implement your business logic - return new GetUserRoleResponseDto(); - } -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleQueryValidator.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleQueryValidator.cs deleted file mode 100644 index b1e96b9..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleQueryValidator.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Queries.GetUserRole; -public class GetUserRoleQueryValidator : AbstractValidator -{ - public GetUserRoleQueryValidator() - { - RuleFor(model => model.Id) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GetUserRoleQuery)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleResponseDto.cs b/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleResponseDto.cs deleted file mode 100644 index 8587d4e..0000000 --- a/src/FrontOffice.BFF.Application/UserRoleCQ/Queries/GetUserRole/GetUserRoleResponseDto.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace FrontOffice.BFF.Application.UserRoleCQ.Queries.GetUserRole; -public class GetUserRoleResponseDto -{ - //شناسه - public long Id { get; set; } - //شناسه نقش - public long RoleId { get; set; } - //شناسه کاربر - public long UserId { get; set; } - -} \ No newline at end of file diff --git a/src/FrontOffice.BFF.Domain/FrontOffice.BFF.Domain.csproj b/src/FrontOffice.BFF.Domain/FrontOffice.BFF.Domain.csproj index b9f81d8..c9634fd 100644 --- a/src/FrontOffice.BFF.Domain/FrontOffice.BFF.Domain.csproj +++ b/src/FrontOffice.BFF.Domain/FrontOffice.BFF.Domain.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/FrontOffice.BFF.Infrastructure/ConfigureServices.cs b/src/FrontOffice.BFF.Infrastructure/ConfigureServices.cs index 4c6014a..02a49f5 100644 --- a/src/FrontOffice.BFF.Infrastructure/ConfigureServices.cs +++ b/src/FrontOffice.BFF.Infrastructure/ConfigureServices.cs @@ -4,6 +4,7 @@ using FrontOffice.BFF.Infrastructure.Services; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; +using Microsoft.IdentityModel.Tokens; namespace Microsoft.Extensions.DependencyInjection; @@ -12,6 +13,7 @@ public static class ConfigureServices public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, IConfiguration configuration) { services.AddSingleton(); + services.AddSingleton(); services.AddInfrastructureGrpcServices(configuration); #region AddAuthentication @@ -19,11 +21,24 @@ public static class ConfigureServices services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(jwtBearerOptions => { - jwtBearerOptions.Authority = configuration["Authentication:Authority"]; - jwtBearerOptions.Audience = configuration["Authentication:Audience"]; - jwtBearerOptions.TokenValidationParameters.ValidateAudience = false; - jwtBearerOptions.TokenValidationParameters.ValidateIssuer = true; - jwtBearerOptions.TokenValidationParameters.ValidateIssuerSigningKey = false; + //jwtBearerOptions.Authority = configuration["Authentication:Authority"]; + //jwtBearerOptions.Audience = configuration["Authentication:Audience"]; + //jwtBearerOptions.TokenValidationParameters.ValidateAudience = false; + //jwtBearerOptions.TokenValidationParameters.ValidateIssuer = true; + //jwtBearerOptions.TokenValidationParameters.ValidateIssuerSigningKey = false; + + jwtBearerOptions.SaveToken = true; + jwtBearerOptions.RequireHttpsMetadata = false; + jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters + { + ValidateIssuer = true, + ValidateAudience = true, + ValidateLifetime = true, + ValidateIssuerSigningKey = true, + ValidIssuer = configuration["JwtIssuer"], + ValidAudience = configuration["JwtAudience"], + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["JwtSecurityKey"])) + }; try { jwtBearerOptions.Events = new JwtBearerEvents diff --git a/src/FrontOffice.BFF.Infrastructure/FrontOffice.BFF.Infrastructure.csproj b/src/FrontOffice.BFF.Infrastructure/FrontOffice.BFF.Infrastructure.csproj index cbacbe6..662eaae 100644 --- a/src/FrontOffice.BFF.Infrastructure/FrontOffice.BFF.Infrastructure.csproj +++ b/src/FrontOffice.BFF.Infrastructure/FrontOffice.BFF.Infrastructure.csproj @@ -7,7 +7,8 @@ - + + diff --git a/src/FrontOffice.BFF.Infrastructure/Services/ApplicationContractContext.cs b/src/FrontOffice.BFF.Infrastructure/Services/ApplicationContractContext.cs index 0105996..b188ad5 100644 --- a/src/FrontOffice.BFF.Infrastructure/Services/ApplicationContractContext.cs +++ b/src/FrontOffice.BFF.Infrastructure/Services/ApplicationContractContext.cs @@ -1,3 +1,8 @@ +using CMSMicroservice.Protobuf.Protos.OtpToken; +using CMSMicroservice.Protobuf.Protos.Package; +using CMSMicroservice.Protobuf.Protos.User; +using CMSMicroservice.Protobuf.Protos.UserAddress; +using CMSMicroservice.Protobuf.Protos.UserOrder; using FrontOffice.BFF.Application.Common.Interfaces; using Microsoft.Extensions.DependencyInjection; @@ -7,7 +12,7 @@ public class ApplicationContractContext : IApplicationContractContext { #region members - private readonly IServiceProvider _serviceProvider; + private readonly IServiceProvider _serviceProvider; #endregion @@ -33,4 +38,15 @@ public class ApplicationContractContext : IApplicationContractContext #endregion + #region CMS + public PackageContract.PackageContractClient Package => GetService(); + + public UserContract.UserContractClient User => GetService(); + + public UserAddressContract.UserAddressContractClient UserAddress => GetService(); + + public UserOrderContract.UserOrderContractClient UserOrder => GetService(); + + public OtpTokenContract.OtpTokenContractClient OtpToken => GetService(); + #endregion } \ No newline at end of file diff --git a/src/FrontOffice.BFF.Infrastructure/Services/KavenegarService.cs b/src/FrontOffice.BFF.Infrastructure/Services/KavenegarService.cs new file mode 100644 index 0000000..ed6c5c3 --- /dev/null +++ b/src/FrontOffice.BFF.Infrastructure/Services/KavenegarService.cs @@ -0,0 +1,45 @@ +using FrontOffice.BFF.Application.Common.Interfaces; + +namespace FrontOffice.BFF.Infrastructure.Services; +public class KavenegarService : IKavenegarService +{ + private Kavenegar.KavenegarApi _kavenegarApi; + public KavenegarService() + { + _kavenegarApi = new Kavenegar.KavenegarApi("497263626F32626A48685A6137524C4F78575A766E4C74694A556B79317648424964655030682B554545413D"); + } + public async Task Send(string mobile, string message) + { + try + { + await _kavenegarApi.Send(sender: "1000001110100", receptor: mobile, message: message); + } + catch (Kavenegar.Core.Exceptions.ApiException ex) + { + // در صورتی که خروجی وب سرویس 200 نباشد این خطارخ می دهد. + Console.Write("Message : " + ex.Message); + } + catch (Kavenegar.Core.Exceptions.HttpException ex) + { + // در زمانی که مشکلی در برقرای ارتباط با وب سرویس وجود داشته باشد این خطا رخ می دهد + Console.Write("Message : " + ex.Message); + } + } + public async Task VerifyLookup(string mobile, string token) + { + try + { + await _kavenegarApi.VerifyLookup(receptor: mobile, token: token, template: "Afrino"); + } + catch (Kavenegar.Core.Exceptions.ApiException ex) + { + // در صورتی که خروجی وب سرویس 200 نباشد این خطارخ می دهد. + Console.Write("Message : " + ex.Message); + } + catch (Kavenegar.Core.Exceptions.HttpException ex) + { + // در زمانی که مشکلی در برقرای ارتباط با وب سرویس وجود داشته باشد این خطا رخ می دهد + Console.Write("Message : " + ex.Message); + } + } +} diff --git a/src/FrontOffice.BFF.WebApi/FrontOffice.BFF.WebApi.csproj b/src/FrontOffice.BFF.WebApi/FrontOffice.BFF.WebApi.csproj index fc19056..f802c22 100644 --- a/src/FrontOffice.BFF.WebApi/FrontOffice.BFF.WebApi.csproj +++ b/src/FrontOffice.BFF.WebApi/FrontOffice.BFF.WebApi.csproj @@ -26,7 +26,5 @@ - - diff --git a/src/FrontOffice.BFF.WebApi/Services/RoleService.cs b/src/FrontOffice.BFF.WebApi/Services/RoleService.cs deleted file mode 100644 index ad08b58..0000000 --- a/src/FrontOffice.BFF.WebApi/Services/RoleService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using FrontOffice.BFF.Role.Protobuf.Protos.Role; -using FrontOffice.BFF.WebApi.Common.Services; -using FrontOffice.BFF.Application.RoleCQ.Commands.CreateNewRole; -using FrontOffice.BFF.Application.RoleCQ.Commands.UpdateRole; -using FrontOffice.BFF.Application.RoleCQ.Commands.DeleteRole; -using FrontOffice.BFF.Application.RoleCQ.Queries.GetRole; -using FrontOffice.BFF.Application.RoleCQ.Queries.GetAllRoleByFilter; -namespace FrontOffice.BFF.WebApi.Services; -public class RoleService : RoleContract.RoleContractBase -{ - private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; - - public RoleService(IDispatchRequestToCQRS dispatchRequestToCQRS) - { - _dispatchRequestToCQRS = dispatchRequestToCQRS; - } - public override async Task CreateNewRole(CreateNewRoleRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task UpdateRole(UpdateRoleRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task DeleteRole(DeleteRoleRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetRole(GetRoleRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetAllRoleByFilter(GetAllRoleByFilterRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } -} diff --git a/src/FrontOffice.BFF.WebApi/Services/UserRoleService.cs b/src/FrontOffice.BFF.WebApi/Services/UserRoleService.cs deleted file mode 100644 index 3dc04a9..0000000 --- a/src/FrontOffice.BFF.WebApi/Services/UserRoleService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using FrontOffice.BFF.UserRole.Protobuf.Protos.UserRole; -using FrontOffice.BFF.WebApi.Common.Services; -using FrontOffice.BFF.Application.UserRoleCQ.Commands.CreateNewUserRole; -using FrontOffice.BFF.Application.UserRoleCQ.Commands.UpdateUserRole; -using FrontOffice.BFF.Application.UserRoleCQ.Commands.DeleteUserRole; -using FrontOffice.BFF.Application.UserRoleCQ.Queries.GetUserRole; -using FrontOffice.BFF.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter; -namespace FrontOffice.BFF.WebApi.Services; -public class UserRoleService : UserRoleContract.UserRoleContractBase -{ - private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; - - public UserRoleService(IDispatchRequestToCQRS dispatchRequestToCQRS) - { - _dispatchRequestToCQRS = dispatchRequestToCQRS; - } - public override async Task CreateNewUserRole(CreateNewUserRoleRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task UpdateUserRole(UpdateUserRoleRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task DeleteUserRole(DeleteUserRoleRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetUserRole(GetUserRoleRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - public override async Task GetAllUserRoleByFilter(GetAllUserRoleByFilterRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } -} diff --git a/src/FrontOffice.BFF.sln b/src/FrontOffice.BFF.sln index 06ca9b0..e7b8455 100644 --- a/src/FrontOffice.BFF.sln +++ b/src/FrontOffice.BFF.sln @@ -14,16 +14,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Protobufs", "Protobufs", "{ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FrontOffice.BFF.Package.Protobuf", "Protobufs\FrontOffice.BFF.Package.Protobuf\FrontOffice.BFF.Package.Protobuf.csproj", "{F4E98BE4-6F95-4B4E-924D-CBAD02AF24F1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FrontOffice.BFF.Role.Protobuf", "Protobufs\FrontOffice.BFF.Role.Protobuf\FrontOffice.BFF.Role.Protobuf.csproj", "{BC01390B-D8D3-4CC3-B900-6EE70A5D76F1}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FrontOffice.BFF.User.Protobuf", "Protobufs\FrontOffice.BFF.User.Protobuf\FrontOffice.BFF.User.Protobuf.csproj", "{C8A16685-0A51-4D1A-B399-FB94C90D9BDC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FrontOffice.BFF.UserAddress.Protobuf", "Protobufs\FrontOffice.BFF.UserAddress.Protobuf\FrontOffice.BFF.UserAddress.Protobuf.csproj", "{D70F0C9A-E954-4A67-B23D-9BE22721BD5D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FrontOffice.BFF.UserOrder.Protobuf", "Protobufs\FrontOffice.BFF.UserOrder.Protobuf\FrontOffice.BFF.UserOrder.Protobuf.csproj", "{663CDDFA-E15F-4356-AE01-2311C9B83D52}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FrontOffice.BFF.UserRole.Protobuf", "Protobufs\FrontOffice.BFF.UserRole.Protobuf\FrontOffice.BFF.UserRole.Protobuf.csproj", "{AD08DE79-6341-4D17-85C4-8705E85CADEA}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -50,10 +46,6 @@ Global {F4E98BE4-6F95-4B4E-924D-CBAD02AF24F1}.Debug|Any CPU.Build.0 = Debug|Any CPU {F4E98BE4-6F95-4B4E-924D-CBAD02AF24F1}.Release|Any CPU.ActiveCfg = Release|Any CPU {F4E98BE4-6F95-4B4E-924D-CBAD02AF24F1}.Release|Any CPU.Build.0 = Release|Any CPU - {BC01390B-D8D3-4CC3-B900-6EE70A5D76F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BC01390B-D8D3-4CC3-B900-6EE70A5D76F1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BC01390B-D8D3-4CC3-B900-6EE70A5D76F1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BC01390B-D8D3-4CC3-B900-6EE70A5D76F1}.Release|Any CPU.Build.0 = Release|Any CPU {C8A16685-0A51-4D1A-B399-FB94C90D9BDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C8A16685-0A51-4D1A-B399-FB94C90D9BDC}.Debug|Any CPU.Build.0 = Debug|Any CPU {C8A16685-0A51-4D1A-B399-FB94C90D9BDC}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -66,20 +58,14 @@ Global {663CDDFA-E15F-4356-AE01-2311C9B83D52}.Debug|Any CPU.Build.0 = Debug|Any CPU {663CDDFA-E15F-4356-AE01-2311C9B83D52}.Release|Any CPU.ActiveCfg = Release|Any CPU {663CDDFA-E15F-4356-AE01-2311C9B83D52}.Release|Any CPU.Build.0 = Release|Any CPU - {AD08DE79-6341-4D17-85C4-8705E85CADEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AD08DE79-6341-4D17-85C4-8705E85CADEA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AD08DE79-6341-4D17-85C4-8705E85CADEA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AD08DE79-6341-4D17-85C4-8705E85CADEA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {F4E98BE4-6F95-4B4E-924D-CBAD02AF24F1} = {CA9BF4D6-6729-4011-888E-48F5F739B469} - {BC01390B-D8D3-4CC3-B900-6EE70A5D76F1} = {CA9BF4D6-6729-4011-888E-48F5F739B469} {C8A16685-0A51-4D1A-B399-FB94C90D9BDC} = {CA9BF4D6-6729-4011-888E-48F5F739B469} {D70F0C9A-E954-4A67-B23D-9BE22721BD5D} = {CA9BF4D6-6729-4011-888E-48F5F739B469} {663CDDFA-E15F-4356-AE01-2311C9B83D52} = {CA9BF4D6-6729-4011-888E-48F5F739B469} - {AD08DE79-6341-4D17-85C4-8705E85CADEA} = {CA9BF4D6-6729-4011-888E-48F5F739B469} EndGlobalSection EndGlobal diff --git a/src/Protobufs/FrontOffice.BFF.Package.Protobuf/Validator/CreateNewPackageRequestValidator.cs b/src/Protobufs/FrontOffice.BFF.Package.Protobuf/Validator/CreateNewPackageRequestValidator.cs deleted file mode 100644 index 48ec793..0000000 --- a/src/Protobufs/FrontOffice.BFF.Package.Protobuf/Validator/CreateNewPackageRequestValidator.cs +++ /dev/null @@ -1,25 +0,0 @@ -using FluentValidation; -using FrontOffice.BFF.Package.Protobuf.Protos.Package; -namespace FrontOffice.BFF.Package.Protobuf.Validator; - -public class CreateNewPackageRequestValidator : AbstractValidator -{ - public CreateNewPackageRequestValidator() - { - RuleFor(model => model.Title) - .NotEmpty(); - RuleFor(model => model.Description) - .NotEmpty(); - RuleFor(model => model.ImagePath) - .NotEmpty(); - RuleFor(model => model.Price) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewPackageRequest)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/Protobufs/FrontOffice.BFF.Package.Protobuf/Validator/DeletePackageRequestValidator.cs b/src/Protobufs/FrontOffice.BFF.Package.Protobuf/Validator/DeletePackageRequestValidator.cs deleted file mode 100644 index aec8c30..0000000 --- a/src/Protobufs/FrontOffice.BFF.Package.Protobuf/Validator/DeletePackageRequestValidator.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentValidation; -using FrontOffice.BFF.Package.Protobuf.Protos.Package; -namespace FrontOffice.BFF.Package.Protobuf.Validator; - -public class DeletePackageRequestValidator : AbstractValidator -{ - public DeletePackageRequestValidator() - { - RuleFor(model => model.Id) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((DeletePackageRequest)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/Protobufs/FrontOffice.BFF.Package.Protobuf/Validator/UpdatePackageRequestValidator.cs b/src/Protobufs/FrontOffice.BFF.Package.Protobuf/Validator/UpdatePackageRequestValidator.cs deleted file mode 100644 index 9041ae9..0000000 --- a/src/Protobufs/FrontOffice.BFF.Package.Protobuf/Validator/UpdatePackageRequestValidator.cs +++ /dev/null @@ -1,27 +0,0 @@ -using FluentValidation; -using FrontOffice.BFF.Package.Protobuf.Protos.Package; -namespace FrontOffice.BFF.Package.Protobuf.Validator; - -public class UpdatePackageRequestValidator : AbstractValidator -{ - public UpdatePackageRequestValidator() - { - RuleFor(model => model.Id) - .NotNull(); - RuleFor(model => model.Title) - .NotEmpty(); - RuleFor(model => model.Description) - .NotEmpty(); - RuleFor(model => model.ImagePath) - .NotEmpty(); - RuleFor(model => model.Price) - .NotNull(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((UpdatePackageRequest)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/Protobufs/FrontOffice.BFF.User.Protobuf/Validator/CreateNewUserRequestValidator.cs b/src/Protobufs/FrontOffice.BFF.User.Protobuf/Validator/CreateNewUserRequestValidator.cs deleted file mode 100644 index c1f0fff..0000000 --- a/src/Protobufs/FrontOffice.BFF.User.Protobuf/Validator/CreateNewUserRequestValidator.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentValidation; -using FrontOffice.BFF.User.Protobuf.Protos.User; -namespace FrontOffice.BFF.User.Protobuf.Validator; - -public class CreateNewUserRequestValidator : AbstractValidator -{ - public CreateNewUserRequestValidator() - { - RuleFor(model => model.Mobile) - .NotEmpty(); - } - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewUserRequest)model, x => x.IncludeProperties(propertyName))); - if (result.IsValid) - return Array.Empty(); - return result.Errors.Select(e => e.ErrorMessage); - }; -}