-
Notifications
You must be signed in to change notification settings - Fork 816
/
Copy pathExampleController.cs
24 lines (18 loc) · 1.04 KB
/
ExampleController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace Architecture.Web;
[ApiController]
[Route("api/examples")]
public sealed class ExampleController : BaseController
{
[HttpPost]
public IActionResult Add(AddExampleRequest request) => Mediator.HandleAsync<AddExampleRequest, long>(request).ApiResult();
[HttpDelete("{id:long}")]
public IActionResult Delete(long id) => Mediator.HandleAsync(new DeleteExampleRequest(id)).ApiResult();
[HttpGet("{id:long}")]
public IActionResult Get(long id) => Mediator.HandleAsync<GetExampleRequest, ExampleModel>(new GetExampleRequest(id)).ApiResult();
[HttpGet("grid")]
public IActionResult Grid([FromQuery] GridExampleRequest request) => Mediator.HandleAsync<GridExampleRequest, Grid<ExampleModel>>(request).ApiResult();
[HttpGet]
public IActionResult List() => Mediator.HandleAsync<ListExampleRequest, IEnumerable<ExampleModel>>(new ListExampleRequest()).ApiResult();
[HttpPut("{id:long}")]
public IActionResult Update(long id, UpdateExampleRequest request) => Mediator.HandleAsync(request with { Id = id }).ApiResult();
}