David Fowler 3b9560c26e
Clean up usings and controller attributes (#2124)
* Clean up usings and controller attributes
- Removed redundant attributes when the controllers already specifies what the result type is.
- Use StatusCodes instead of HttpStatusCode.
- Clean up namespaces and use type aliases to disambiguate the many DTOs defined.

* Forgot one

* Update src/Services/Webhooks/Webhooks.API/Controllers/WebhooksController.cs

Co-authored-by: Reuben Bond <203839+ReubenBond@users.noreply.github.com>

---------

Co-authored-by: Reuben Bond <203839+ReubenBond@users.noreply.github.com>
2023-06-14 20:56:52 -07:00

37 lines
1.1 KiB
C#

namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Controllers;
[Route("api/v1/[controller]")]
[Authorize]
[ApiController]
public class OrderController : ControllerBase
{
private readonly IBasketService _basketService;
private readonly IOrderingService _orderingService;
public OrderController(IBasketService basketService, IOrderingService orderingService)
{
_basketService = basketService;
_orderingService = orderingService;
}
[Route("draft/{basketId}")]
[HttpGet]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<ActionResult<OrderData>> GetOrderDraftAsync(string basketId)
{
if (string.IsNullOrEmpty(basketId))
{
return BadRequest("Need a valid basketid");
}
// Get the basket data and build a order draft based on it
var basket = await _basketService.GetByIdAsync(basketId);
if (basket == null)
{
return BadRequest($"No basket found for id {basketId}");
}
return await _orderingService.GetOrderDraftAsync(basket);
}
}