diff --git a/samples/apis/Product.Api/Application/Command/AddProductTypeCommand.cs b/samples/apis/Product.Api/Application/Command/AddProductTypeCommand.cs deleted file mode 100644 index 9647a16..0000000 --- a/samples/apis/Product.Api/Application/Command/AddProductTypeCommand.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Pole.Application.Command; -using Pole.Application.Cqrs; -using Pole.Grpc.ExtraType; -using PoleSample.Apis.Product; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Product.Api.Application.Command -{ - public class AddProductTypeCommand: ICommand - { - public AddProductTypeRequest Request { get; set; } - } -} diff --git a/samples/apis/Product.Api/Application/Command/CommandHandler/AddProductTypeCommandHandler.cs b/samples/apis/Product.Api/Application/CommandHandler/AddProductTypeCommandHandler.cs similarity index 85% rename from samples/apis/Product.Api/Application/Command/CommandHandler/AddProductTypeCommandHandler.cs rename to samples/apis/Product.Api/Application/CommandHandler/AddProductTypeCommandHandler.cs index c23894d..f41998d 100644 --- a/samples/apis/Product.Api/Application/Command/CommandHandler/AddProductTypeCommandHandler.cs +++ b/samples/apis/Product.Api/Application/CommandHandler/AddProductTypeCommandHandler.cs @@ -12,9 +12,9 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -namespace Product.Api.Application.Command.CommandHandler +namespace Product.Api.Application.CommandHandler { - public class AddProductTypeCommandHandler : ICommandHandler + public class AddProductTypeCommandHandler : ICommandHandler, CommonCommandResponse> { private readonly IProductTypeRepository _productTypeRepository; private readonly IUnitOfWorkManager _unitOfWorkManager; @@ -23,9 +23,9 @@ namespace Product.Api.Application.Command.CommandHandler _productTypeRepository = productTypeRepository; _unitOfWorkManager = unitOfWorkManager; } - public async Task Handle(AddProductTypeCommand request, CancellationToken cancellationToken) + public async Task Handle(Command request, CancellationToken cancellationToken) { - var productType = new Domain.ProductTypeAggregate.ProductType(request.Request.Id, request.Request.Name); + var productType = new Domain.ProductTypeAggregate.ProductType(request.Data.Id, request.Data.Name); _productTypeRepository.Add(productType); diff --git a/samples/apis/Product.Api/Grpc/ProductTypeService.cs b/samples/apis/Product.Api/Grpc/ProductTypeService.cs index 37fbd16..57568e9 100644 --- a/samples/apis/Product.Api/Grpc/ProductTypeService.cs +++ b/samples/apis/Product.Api/Grpc/ProductTypeService.cs @@ -4,7 +4,6 @@ using Pole.Application.Command; using Pole.Application.Cqrs; using Pole.Grpc.ExtraType; using PoleSample.Apis.Product; -using Product.Api.Application.Command; using Product.Api.Infrastructure; using System; using System.Collections.Generic; @@ -22,7 +21,7 @@ namespace Product.Api.Grpc } public override Task Add(AddProductTypeRequest request, ServerCallContext context) { - var cpmmand = new AddProductTypeCommand { Request = request }; + var cpmmand = new Command(request); return _commandBus.Send(cpmmand); } } diff --git a/src/Pole.Application/Command/Command.cs b/src/Pole.Application/Command/Command.cs new file mode 100644 index 0000000..c71ac02 --- /dev/null +++ b/src/Pole.Application/Command/Command.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Pole.Application.Command +{ + public class Command:ICommand + { + public Command(TRequest request) + { + Data = request; + } + public TRequest Data { get; private set; } + } +}