Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
丁松杰
/
Pole
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
93236c4c
authored
Jan 16, 2020
by
dingsongjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
简化 command
parent
76b0558a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
22 deletions
samples/apis/Product.Api/Application/Command/AddProductTypeCommand.cs
samples/apis/Product.Api/Application/Command/CommandHandler/AddProductTypeCommandHandler.cs → samples/apis/Product.Api/Application/CommandHandler/AddProductTypeCommandHandler.cs
samples/apis/Product.Api/Grpc/ProductTypeService.cs
src/Pole.Application/Command/Command.cs
samples/apis/Product.Api/Application/Command/AddProductTypeCommand.cs
deleted
100644 → 0
View file @
76b0558a
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
<
CommonCommandResponse
>
{
public
AddProductTypeRequest
Request
{
get
;
set
;
}
}
}
samples/apis/Product.Api/Application/Command
/Command
Handler/AddProductTypeCommandHandler.cs
→
samples/apis/Product.Api/Application/CommandHandler/AddProductTypeCommandHandler.cs
View file @
93236c4c
...
...
@@ -12,9 +12,9 @@ using System.Linq;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
Product.Api.Application.Command
.Command
Handler
namespace
Product.Api.Application.CommandHandler
{
public
class
AddProductTypeCommandHandler
:
ICommandHandler
<
AddProductTypeCommand
,
CommonCommandResponse
>
public
class
AddProductTypeCommandHandler
:
ICommandHandler
<
Command
<
AddProductTypeRequest
,
CommonCommandResponse
>
,
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
<
CommonCommandResponse
>
Handle
(
AddProductTypeCommand
request
,
CancellationToken
cancellationToken
)
public
async
Task
<
CommonCommandResponse
>
Handle
(
Command
<
AddProductTypeRequest
,
CommonCommandResponse
>
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
);
...
...
samples/apis/Product.Api/Grpc/ProductTypeService.cs
View file @
93236c4c
...
...
@@ -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
<
CommonCommandResponse
>
Add
(
AddProductTypeRequest
request
,
ServerCallContext
context
)
{
var
cpmmand
=
new
AddProductTypeCommand
{
Request
=
request
}
;
var
cpmmand
=
new
Command
<
AddProductTypeRequest
,
CommonCommandResponse
>(
request
)
;
return
_commandBus
.
Send
(
cpmmand
);
}
}
...
...
src/Pole.Application/Command/Command.cs
0 → 100644
View file @
93236c4c
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Pole.Application.Command
{
public
class
Command
<
TRequest
,
TResponse
>:
ICommand
<
TResponse
>
{
public
Command
(
TRequest
request
)
{
Data
=
request
;
}
public
TRequest
Data
{
get
;
private
set
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment