4
4
using Cnblogs . Architecture . Ddd . Cqrs . Abstractions ;
5
5
using Microsoft . AspNetCore . Builder ;
6
6
using Microsoft . AspNetCore . Http ;
7
+ using Microsoft . AspNetCore . Mvc ;
7
8
using Microsoft . AspNetCore . Routing ;
8
9
using Microsoft . AspNetCore . Routing . Patterns ;
9
10
@@ -206,6 +207,20 @@ public static IEndpointConventionBuilder MapCommand(
206
207
return app . MapPutCommand ( route , handler ) ;
207
208
}
208
209
210
+ /// <summary>
211
+ /// Map a command API, using POST method and get command data from request body.
212
+ /// </summary>
213
+ /// <param name="app"><see cref="ApplicationBuilder"/></param>
214
+ /// <param name="route">The route template.</param>
215
+ /// <typeparam name="TCommand">The type of command.</typeparam>
216
+ /// <returns></returns>
217
+ public static IEndpointConventionBuilder MapPostCommand < TCommand > (
218
+ this IEndpointRouteBuilder app ,
219
+ [ StringSyntax ( "Route" ) ] string route )
220
+ {
221
+ return app . MapPostCommand ( route , ( [ FromBody ] TCommand command ) => command ) ;
222
+ }
223
+
209
224
/// <summary>
210
225
/// Map a command API, using POST method.
211
226
/// </summary>
@@ -222,6 +237,20 @@ public static IEndpointConventionBuilder MapPostCommand(
222
237
return app . MapPost ( route , handler ) . AddEndpointFilter < CommandEndpointHandler > ( ) ;
223
238
}
224
239
240
+ /// <summary>
241
+ /// Map a command API, using PUT method and get command data from request body.
242
+ /// </summary>
243
+ /// <param name="app"><see cref="IEndpointRouteBuilder"/></param>
244
+ /// <param name="route">The route template.</param>
245
+ /// <typeparam name="TCommand">The type of command.</typeparam>
246
+ /// <returns></returns>
247
+ public static IEndpointConventionBuilder MapPutCommand < TCommand > (
248
+ this IEndpointRouteBuilder app ,
249
+ [ StringSyntax ( "Route" ) ] string route )
250
+ {
251
+ return app . MapPutCommand ( route , ( [ FromBody ] TCommand command ) => command ) ;
252
+ }
253
+
225
254
/// <summary>
226
255
/// Map a command API, using PUT method.
227
256
/// </summary>
@@ -238,6 +267,20 @@ public static IEndpointConventionBuilder MapPutCommand(
238
267
return app . MapPut ( route , handler ) . AddEndpointFilter < CommandEndpointHandler > ( ) ;
239
268
}
240
269
270
+ /// <summary>
271
+ /// Map a command API, using DELETE method and get command from route/query parameters.
272
+ /// </summary>
273
+ /// <param name="app"><see cref="IEndpointRouteBuilder"/></param>
274
+ /// <param name="route">The route template.</param>
275
+ /// <typeparam name="TCommand">The type of command.</typeparam>
276
+ /// <returns></returns>
277
+ public static IEndpointConventionBuilder MapDeleteCommand < TCommand > (
278
+ this IEndpointRouteBuilder app ,
279
+ [ StringSyntax ( "Route" ) ] string route )
280
+ {
281
+ return app . MapDeleteCommand ( route , ( [ AsParameters ] TCommand command ) => command ) ;
282
+ }
283
+
241
284
/// <summary>
242
285
/// Map a command API, using DELETE method.
243
286
/// </summary>
0 commit comments