Я делаю это уже несколько часов. Что я здесь делаю не так?
BaseController Route
[Route("api/v{v:apiVersion}/[controller]")]
[ApiController]
[Authorize]
public class BaseControllerV2 : ControllerBase
{
}
Controller Route
public class OrdersController : BaseControllerV2
{
private readonly IOrderService _iOrderService;
public OrdersController(IOrderService iOrderService)
{
_iOrderService = iOrderService;
}
/// <summary>
/// Retrieve order details
/// </summary>
[HttpGet("{orderNo:int}", Name = nameof(GetOrderByOrderNo))]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<Business.Models.V2.Order>> GetOrderByOrderNo([FromRoute]int orderNo, [BindRequired, FromQuery]int agencyNo, CancellationToken cancellationToken)
{
var result = await _iOrderService.GetOrderByOrderNo(orderNo, agencyNo, cancellationToken);
if (result == null) return NotFound();
return Ok(result);
}
/// <summary>
/// Create quote
/// </summary>
[HttpPost(Name = nameof(CreateQuote))]
[ProducesResponseType(StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<Business.Models.V2.Order>> CreateQuote([FromBody]Business.Models.V2.Order order, CancellationToken cancellationToken)
{
var result = await _iOrderService.CreateQuote(order, cancellationToken);
return CreatedAtAction(nameof(GetOrderByOrderNo), new { orderNo = result.OrderNo, agencyNo = result.AgencyNo, cancellationToken}, result);
}
}
Я попробовал решить другие связанные вопросы, но CreatedAtAction все еще не может найти конечную точку.