-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
CarsController.cs
43 lines (39 loc) · 1.34 KB
/
CarsController.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using HappyCode.NetCoreBoilerplate.Core;
using HappyCode.NetCoreBoilerplate.Core.Dtos;
using HappyCode.NetCoreBoilerplate.Core.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.FeatureManagement.Mvc;
namespace HappyCode.NetCoreBoilerplate.Api.Controllers
{
[FeatureGate(FeatureFlags.DockerCompose)]
[Route("api/cars")]
public class CarsController : ApiControllerBase
{
private readonly ICarService _carService;
public CarsController(ICarService carService)
{
_carService = carService;
}
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<CarDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetAllAsync(
CancellationToken cancellationToken = default)
{
var result = await _carService.GetAllSortedByPlateAsync(cancellationToken);
return Ok(result);
}
[FeatureGate(FeatureFlags.Santa)]
[HttpGet("santa")]
[ProducesResponseType(typeof(CarDto), StatusCodes.Status200OK)]
public IActionResult GetSantaCar()
{
return Ok(new CarDto
{
Id = int.MaxValue,
Model = "Magic Sleigh",
Plate = "XMas 12",
});
}
}
}