Owneat Technical Guide main Help

Class OrderController

Namespace: Ordering.API.Controllers
Assembly: Ordering.API.dll

Controller that manage Ordering.Domain.Aggregates.OrderAggregate.Orders.

[ApiController] [ApiVersion("1.0")] [Route("api/v{version:apiVersion}/[controller]s")] public sealed class OrderController : ControllerBase

Inheritance

objectControllerBase ← OrderController

Inherited Members

ControllerBase.StatusCode\(int\), ControllerBase.StatusCode\(int, object?\), ControllerBase.Content\(string\), ControllerBase.Content\(string, string\), ControllerBase.Content\(string, string, Encoding\), ControllerBase.Content\(string, MediaTypeHeaderValue?\), ControllerBase.NoContent\(\), ControllerBase.Ok\(\), ControllerBase.Ok\(object?\), ControllerBase.Redirect\(string\), ControllerBase.RedirectPermanent\(string\), ControllerBase.RedirectPreserveMethod\(string\), ControllerBase.RedirectPermanentPreserveMethod\(string\), ControllerBase.LocalRedirect\(string\), ControllerBase.LocalRedirectPermanent\(string\), ControllerBase.LocalRedirectPreserveMethod\(string\), ControllerBase.LocalRedirectPermanentPreserveMethod\(string\), ControllerBase.RedirectToAction\(\), ControllerBase.RedirectToAction\(string?\), ControllerBase.RedirectToAction\(string?, object?\), ControllerBase.RedirectToAction\(string?, string?\), ControllerBase.RedirectToAction\(string?, string?, object?\), ControllerBase.RedirectToAction\(string?, string?, string?\), ControllerBase.RedirectToAction\(string?, string?, object?, string?\), ControllerBase.RedirectToActionPreserveMethod\(string?, string?, object?, string?\), ControllerBase.RedirectToActionPermanent\(string?\), ControllerBase.RedirectToActionPermanent\(string?, object?\), ControllerBase.RedirectToActionPermanent\(string?, string?\), ControllerBase.RedirectToActionPermanent\(string?, string?, string?\), ControllerBase.RedirectToActionPermanent\(string?, string?, object?\), ControllerBase.RedirectToActionPermanent\(string?, string?, object?, string?\), ControllerBase.RedirectToActionPermanentPreserveMethod\(string?, string?, object?, string?\), ControllerBase.RedirectToRoute\(string?\), ControllerBase.RedirectToRoute\(object?\), ControllerBase.RedirectToRoute\(string?, object?\), ControllerBase.RedirectToRoute\(string?, string?\), ControllerBase.RedirectToRoute\(string?, object?, string?\), ControllerBase.RedirectToRoutePreserveMethod\(string?, object?, string?\), ControllerBase.RedirectToRoutePermanent\(string?\), ControllerBase.RedirectToRoutePermanent\(object?\), ControllerBase.RedirectToRoutePermanent\(string?, object?\), ControllerBase.RedirectToRoutePermanent\(string?, string?\), ControllerBase.RedirectToRoutePermanent\(string?, object?, string?\), ControllerBase.RedirectToRoutePermanentPreserveMethod\(string?, object?, string?\), ControllerBase.RedirectToPage\(string\), ControllerBase.RedirectToPage\(string, object?\), ControllerBase.RedirectToPage\(string, string?\), ControllerBase.RedirectToPage\(string, string?, object?\), ControllerBase.RedirectToPage\(string, string?, string?\), ControllerBase.RedirectToPage\(string, string?, object?, string?\), ControllerBase.RedirectToPagePermanent\(string\), ControllerBase.RedirectToPagePermanent\(string, object?\), ControllerBase.RedirectToPagePermanent\(string, string?\), ControllerBase.RedirectToPagePermanent\(string, string?, string?\), ControllerBase.RedirectToPagePermanent\(string, string?, object?, string?\), ControllerBase.RedirectToPagePreserveMethod\(string, string?, object?, string?\), ControllerBase.RedirectToPagePermanentPreserveMethod\(string, string?, object?, string?\), ControllerBase.File\(byte\[\], string\), ControllerBase.File\(byte\[\], string, bool\), ControllerBase.File\(byte\[\], string, string?\), ControllerBase.File\(byte\[\], string, string?, bool\), ControllerBase.File\(byte\[\], string, DateTimeOffset?, EntityTagHeaderValue\), ControllerBase.File\(byte\[\], string, DateTimeOffset?, EntityTagHeaderValue, bool\), ControllerBase.File\(byte\[\], string, string?, DateTimeOffset?, EntityTagHeaderValue\), ControllerBase.File\(byte\[\], string, string?, DateTimeOffset?, EntityTagHeaderValue, bool\), ControllerBase.File\(Stream, string\), ControllerBase.File\(Stream, string, bool\), ControllerBase.File\(Stream, string, string?\), ControllerBase.File\(Stream, string, string?, bool\), ControllerBase.File\(Stream, string, DateTimeOffset?, EntityTagHeaderValue\), ControllerBase.File\(Stream, string, DateTimeOffset?, EntityTagHeaderValue, bool\), ControllerBase.File\(Stream, string, string?, DateTimeOffset?, EntityTagHeaderValue\), ControllerBase.File\(Stream, string, string?, DateTimeOffset?, EntityTagHeaderValue, bool\), ControllerBase.File\(string, string\), ControllerBase.File\(string, string, bool\), ControllerBase.File\(string, string, string?\), ControllerBase.File\(string, string, string?, bool\), ControllerBase.File\(string, string, DateTimeOffset?, EntityTagHeaderValue\), ControllerBase.File\(string, string, DateTimeOffset?, EntityTagHeaderValue, bool\), ControllerBase.File\(string, string, string?, DateTimeOffset?, EntityTagHeaderValue\), ControllerBase.File\(string, string, string?, DateTimeOffset?, EntityTagHeaderValue, bool\), ControllerBase.PhysicalFile\(string, string\), ControllerBase.PhysicalFile\(string, string, bool\), ControllerBase.PhysicalFile\(string, string, string?\), ControllerBase.PhysicalFile\(string, string, string?, bool\), ControllerBase.PhysicalFile\(string, string, DateTimeOffset?, EntityTagHeaderValue\), ControllerBase.PhysicalFile\(string, string, DateTimeOffset?, EntityTagHeaderValue, bool\), ControllerBase.PhysicalFile\(string, string, string?, DateTimeOffset?, EntityTagHeaderValue\), ControllerBase.PhysicalFile\(string, string, string?, DateTimeOffset?, EntityTagHeaderValue, bool\), ControllerBase.Unauthorized\(\), ControllerBase.Unauthorized\(object?\), ControllerBase.NotFound\(\), ControllerBase.NotFound\(object?\), ControllerBase.BadRequest\(\), ControllerBase.BadRequest\(object?\), ControllerBase.BadRequest\(ModelStateDictionary\), ControllerBase.UnprocessableEntity\(\), ControllerBase.UnprocessableEntity\(object?\), ControllerBase.UnprocessableEntity\(ModelStateDictionary\), ControllerBase.Conflict\(\), ControllerBase.Conflict\(object?\), ControllerBase.Conflict\(ModelStateDictionary\), ControllerBase.Problem\(string?, string?, int?, string?, string?\), ControllerBase.ValidationProblem\(ValidationProblemDetails\), ControllerBase.ValidationProblem\(ModelStateDictionary\), ControllerBase.ValidationProblem\(\), ControllerBase.ValidationProblem\(string?, string?, int?, string?, string?, ModelStateDictionary?\), ControllerBase.Created\(\), ControllerBase.Created\(string?, object?\), ControllerBase.Created\(Uri?, object?\), ControllerBase.CreatedAtAction\(string?, object?\), ControllerBase.CreatedAtAction\(string?, object?, object?\), ControllerBase.CreatedAtAction\(string?, string?, object?, object?\), ControllerBase.CreatedAtRoute\(string?, object?\), ControllerBase.CreatedAtRoute\(object?, object?\), ControllerBase.CreatedAtRoute\(string?, object?, object?\), ControllerBase.Accepted\(\), ControllerBase.Accepted\(object?\), ControllerBase.Accepted\(Uri\), ControllerBase.Accepted\(string?\), ControllerBase.Accepted\(string?, object?\), ControllerBase.Accepted\(Uri, object?\), ControllerBase.AcceptedAtAction\(string?\), ControllerBase.AcceptedAtAction\(string?, string?\), ControllerBase.AcceptedAtAction\(string?, object?\), ControllerBase.AcceptedAtAction\(string?, string?, object?\), ControllerBase.AcceptedAtAction\(string?, object?, object?\), ControllerBase.AcceptedAtAction\(string?, string?, object?, object?\), ControllerBase.AcceptedAtRoute\(object?\), ControllerBase.AcceptedAtRoute\(string?\), ControllerBase.AcceptedAtRoute\(string?, object?\), ControllerBase.AcceptedAtRoute\(object?, object?\), ControllerBase.AcceptedAtRoute\(string?, object?, object?\), ControllerBase.Challenge\(\), ControllerBase.Challenge\(params string\[\]\), ControllerBase.Challenge\(AuthenticationProperties\), ControllerBase.Challenge\(AuthenticationProperties, params string\[\]\), ControllerBase.Forbid\(\), ControllerBase.Forbid\(params string\[\]\), ControllerBase.Forbid\(AuthenticationProperties\), ControllerBase.Forbid\(AuthenticationProperties, params string\[\]\), ControllerBase.SignIn\(ClaimsPrincipal\), ControllerBase.SignIn\(ClaimsPrincipal, string\), ControllerBase.SignIn\(ClaimsPrincipal, AuthenticationProperties\), ControllerBase.SignIn\(ClaimsPrincipal, AuthenticationProperties, string\), ControllerBase.SignOut\(\), ControllerBase.SignOut\(AuthenticationProperties\), ControllerBase.SignOut\(params string\[\]\), ControllerBase.SignOut\(AuthenticationProperties, params string\[\]\), ControllerBase.TryUpdateModelAsync<TModel\>\(TModel\), ControllerBase.TryUpdateModelAsync<TModel\>\(TModel, string\), ControllerBase.TryUpdateModelAsync<TModel\>\(TModel, string, IValueProvider\), ControllerBase.TryUpdateModelAsync<TModel\>\(TModel, string, params Expression<Func<TModel, object?\>\>\[\]\), ControllerBase.TryUpdateModelAsync<TModel\>\(TModel, string, Func<ModelMetadata, bool\>\), ControllerBase.TryUpdateModelAsync<TModel\>\(TModel, string, IValueProvider, params Expression<Func<TModel, object?\>\>\[\]\), ControllerBase.TryUpdateModelAsync<TModel\>\(TModel, string, IValueProvider, Func<ModelMetadata, bool\>\), ControllerBase.TryUpdateModelAsync\(object, Type, string\), ControllerBase.TryUpdateModelAsync\(object, Type, string, IValueProvider, Func<ModelMetadata, bool\>\), ControllerBase.TryValidateModel\(object\), ControllerBase.TryValidateModel\(object, string?\), ControllerBase.HttpContext, ControllerBase.Request, ControllerBase.Response, ControllerBase.RouteData, ControllerBase.ModelState, ControllerBase.ControllerContext, ControllerBase.MetadataProvider, ControllerBase.ModelBinderFactory, ControllerBase.Url, ControllerBase.ObjectValidator, ControllerBase.ProblemDetailsFactory, ControllerBase.User, ControllerBase.Empty, object.Equals\(object?\), object.Equals\(object?, object?\), object.GetHashCode\(\), object.GetType\(\), object.ReferenceEquals\(object?, object?\), object.ToString\(\)

Constructors

OrderController\(IMediator\)

Ordering.Domain.Aggregates.OrderAggregate.Order controller constructor, injecting MediatR.IMediator to send requests.

public OrderController(IMediator mediator)

Parameters

mediator IMediator

The MediatR.IMediator to inject for mediator query handling.

Methods

CancelOrder\(Guid\)

Cancel an existing order.

[HttpPut("{orderGuid}/cancel")] [Authorize(Roles = "Admin, Owner, Staff")] [ProducesResponseType(typeof(Order), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<Order>> CancelOrder(Guid orderGuid)

Parameters

orderGuid Guid

The unique identifier of the order to cancel.

Returns

Task < ActionResult <Order\>\>

CancelOrderLineItem\(Guid, Guid\)

Cancel an order line item.

[HttpPut("{orderGuid}/line-items/{orderLineItemGuid}/cancel")] [ProducesResponseType(204)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] public Task<ActionResult<Unit>> CancelOrderLineItem(Guid orderGuid, Guid orderLineItemGuid)

Parameters

orderGuid Guid

The unique identifier of the order which contains the item to cancel.

orderLineItemGuid Guid

The unique identifier of the order line item to cancel.

Returns

Task < ActionResult <Unit\>\>

CreateOrder\(CreateOrderCommand\)

Create a new order.

[HttpPost] [ProducesResponseType(typeof(Order), 201)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(409)] [ProducesResponseType(500)] [ProducesResponseType(503)] public Task<ActionResult<Order>> CreateOrder(CreateOrderCommand command)

Parameters

command CreateOrderCommand

The order infos to create.

Returns

Task < ActionResult <Order\>\>

DeleteOrder\(Guid\)

Delete a order.

[HttpDelete("{orderGuid}")] [ProducesResponseType(204)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] public Task<ActionResult<Unit>> DeleteOrder(Guid orderGuid)

Parameters

orderGuid Guid

The unique identifier of the order to delete.

Returns

Task < ActionResult <Unit\>\>

GetAllOrders\(\)

Get the list of all orders.

[HttpGet] [ProducesResponseType(typeof(IEnumerable<Order>), 200)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(500)] public Task<ActionResult<IEnumerable<Order>>> GetAllOrders()

Returns

Task < ActionResult < IEnumerable <Order\>\>\>

GetOrderById\(Guid\)

Get a specific order by their unique identifier.

[HttpGet("{orderGuid}")] [ProducesResponseType(typeof(Order), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<Order>> GetOrderById(Guid orderGuid)

Parameters

orderGuid Guid

The unique identifier for the order.

Returns

Task < ActionResult <Order\>\>

MarkAllOrderLineItemsAsAcknowledged\(Guid\)

Mark all order line items as acknowledged.

[HttpPut("{orderGuid}/mark-all-items-as-acknowledged")] [ProducesResponseType(typeof(Order), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(500)] public Task<ActionResult<Unit>> MarkAllOrderLineItemsAsAcknowledged(Guid orderGuid)

Parameters

orderGuid Guid

Returns

Task < ActionResult <Unit\>\>

MarkSingleOrderLineItemAsAcknowledged\(Guid, Guid\)

Mark a single order line item as acknowledged.

[HttpPut("{orderGuid}/line-items/{orderLineItemGuid}/mark-as-acknowledged")] [ProducesResponseType(typeof(OrderLineItem), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(500)] public Task<ActionResult<Unit>> MarkSingleOrderLineItemAsAcknowledged(Guid orderGuid, Guid orderLineItemGuid)

Parameters

orderGuid Guid

orderLineItemGuid Guid

Returns

Task < ActionResult <Unit\>\>

ServeOrder\(Guid\)

Serve an existing order.

[HttpPut("{orderGuid}/serve")] [Authorize(Roles = "Admin, Owner, Staff")] [ProducesResponseType(typeof(Order), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<Order>> ServeOrder(Guid orderGuid)

Parameters

orderGuid Guid

Returns

Task < ActionResult <Order\>\>

ServeOrderLineItem\(Guid, Guid\)

Serve an order line item.

[HttpPut("{orderGuid}/line-items/{orderLineItemGuid}/serve")] [ProducesResponseType(204)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] public Task<ActionResult<Unit>> ServeOrderLineItem(Guid orderGuid, Guid orderLineItemGuid)

Parameters

orderGuid Guid

The unique identifier of the order which contains the item to serve.

orderLineItemGuid Guid

The unique identifier of the order line item to serve.

Returns

Task < ActionResult <Unit\>\>

ToggleOrderLineItemPayingCustomerId\(Guid, Guid, ToggleOrderLineItemPayingCustomerIdCommand\)

Toggle the paying customer id of an order line item.

[RateLimit(PeriodInSec = 5, Limit = 1, RouteParams = "orderGuid,orderLineItemGuid")] [HttpPut("{orderGuid}/line-items/{orderLineItemGuid}/toggle-paying-customer")] [ProducesResponseType(typeof(OrderLineItem), 200)] [ProducesResponseType(400)] [ProducesResponseType(403)] [ProducesResponseType(500)] public Task<ActionResult<Unit>> ToggleOrderLineItemPayingCustomerId(Guid orderGuid, Guid orderLineItemGuid, ToggleOrderLineItemPayingCustomerIdCommand command)

Parameters

orderGuid Guid

The unique identifier of the order.

orderLineItemGuid Guid

The unique identifier of the order line item.

command ToggleOrderLineItemPayingCustomerIdCommand

The command that contains the infos to toggle the paying customer id.

Returns

Task < ActionResult <Unit\>\>

UpdateOrderLineItemQuantity\(Guid, Guid, UpdateOrderLineItemQuantityCommand\)

Update the quantity of an order line item.

[HttpPut("{orderGuid}/line-items/{orderLineItemGuid}/quantity")] [ProducesResponseType(typeof(OrderLineItem), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(500)] public Task<ActionResult<Order>> UpdateOrderLineItemQuantity(Guid orderGuid, Guid orderLineItemGuid, UpdateOrderLineItemQuantityCommand command)

Parameters

orderGuid Guid

The unique identifier of the order.

orderLineItemGuid Guid

The unique identifier of the order line item.

command UpdateOrderLineItemQuantityCommand

The command that contains the infos to toggle the paying customer id.

Returns

Task < ActionResult <Order\>\>

Last modified: 21 May 2024