Skip to content

Commit 589f13a

Browse files
author
Bruce.L
committed
Restful
1 parent cd8fc89 commit 589f13a

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

src/Wax.Api/Controllers/CustomerController.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using Mediator.Net;
2-
using Microsoft.AspNetCore.Mvc;
3-
41
namespace Wax.Api.Controllers
52
{
63
[ApiController]
@@ -32,11 +29,18 @@ public async Task<IActionResult> CreateAsync([FromBody] CreateCustomerCommand co
3229
return CreatedAtAction("GetList", response);
3330
}
3431

35-
[HttpPut]
32+
[HttpPut("{customerId:guid}")]
3633
[ProducesResponseType(204)]
37-
public async Task<IActionResult> UpdateAsync([FromBody] UpdateCustomerCommand command)
34+
public async Task<IActionResult> UpdateAsync(Guid customerId, [FromBody] UpdateCustomerModel model)
3835
{
39-
await _mediator.SendAsync(command);
36+
await _mediator.SendAsync(new UpdateCustomerCommand
37+
{
38+
CustomerId = customerId,
39+
Name = model.Name,
40+
Contact = model.Contact,
41+
Address = model.Address
42+
});
43+
4044
return NoContent();
4145
}
4246

src/Wax.Api/GlobalUsings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Global using directives
22

33
global using Autofac;
4+
global using Mediator.Net;
5+
global using Microsoft.AspNetCore.Mvc;
46
global using Serilog;
57
global using Wax.Api.Extensions;
8+
global using Wax.Api.Models;
69
global using Wax.Core;
710
global using Wax.Core.Commands.Customers;
811
global using Wax.Core.Requests;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Wax.Api.Models;
2+
3+
public class UpdateCustomerModel
4+
{
5+
public string Name { get; set; }
6+
public string Contact { get; set; }
7+
public string Address { get; set; }
8+
}

0 commit comments

Comments
 (0)