44using Cnblogs . Architecture . Ddd . Cqrs . Abstractions ;
55using Microsoft . AspNetCore . Builder ;
66using Microsoft . AspNetCore . Http ;
7+ using Microsoft . AspNetCore . Mvc ;
78using Microsoft . AspNetCore . Routing ;
89using Microsoft . AspNetCore . Routing . Patterns ;
910
@@ -206,6 +207,20 @@ public static IEndpointConventionBuilder MapCommand(
206207 return app . MapPutCommand ( route , handler ) ;
207208 }
208209
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+
209224 /// <summary>
210225 /// Map a command API, using POST method.
211226 /// </summary>
@@ -222,6 +237,20 @@ public static IEndpointConventionBuilder MapPostCommand(
222237 return app . MapPost ( route , handler ) . AddEndpointFilter < CommandEndpointHandler > ( ) ;
223238 }
224239
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+
225254 /// <summary>
226255 /// Map a command API, using PUT method.
227256 /// </summary>
@@ -238,6 +267,20 @@ public static IEndpointConventionBuilder MapPutCommand(
238267 return app . MapPut ( route , handler ) . AddEndpointFilter < CommandEndpointHandler > ( ) ;
239268 }
240269
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+
241284 /// <summary>
242285 /// Map a command API, using DELETE method.
243286 /// </summary>
0 commit comments