Owneat Technical Guide main Help

Class RestaurantController

Namespace: Restaurant.API.Controllers
Assembly: Restaurant.API.dll

Class defining endpoints for Restaurant entity.

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

Inheritance

objectControllerBase ← RestaurantController

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

RestaurantController\(IMediator\)

Create an instance of Restaurant.API.Controllers.RestaurantController and injecting MediatR.IMediator for CQRS use.

public RestaurantController(IMediator mediator)

Parameters

mediator IMediator

Methods

AddMenu\(Guid, Guid\)

Add a menu to a restaurant.

[HttpPut("{restaurantGuid}/menus/{menuGuid}")] [Authorize(Roles = "Admin")] [ProducesResponseType(typeof(Restaurant), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(409)] [ProducesResponseType(500)] public Task<ActionResult<Restaurant>> AddMenu(Guid restaurantGuid, Guid menuGuid)

Parameters

restaurantGuid Guid

Guid of the restaurant.

menuGuid Guid

Guid of the menu.

Returns

Task < ActionResult <Restaurant\>\>

The updated restaurant.

CreateMenu\(Guid, CreateRestaurantMenuCategoryCommand\)

Create a menu in a restaurant.

[HttpPut("{restaurantGuid}/menus")] [Authorize(Roles = "Admin, Owner")] [ProducesResponseType(typeof(Restaurant), 201)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(409)] [ProducesResponseType(500)] public Task<ActionResult<Restaurant>> CreateMenu(Guid restaurantGuid, CreateRestaurantMenuCategoryCommand command)

Parameters

restaurantGuid Guid

Guid of the restaurant.

command CreateRestaurantMenuCategoryCommand

The command to create a menu in a restaurant.

Returns

Task < ActionResult <Restaurant\>\>

The updated restaurant.

CreateRestaurant\(CreateRestaurantCommand\)

Create a restaurant.

[HttpPost] [Authorize(Roles = "Admin")] [ProducesResponseType(typeof(Restaurant), 201)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(409)] [ProducesResponseType(500)] public Task<ActionResult<Restaurant>> CreateRestaurant(CreateRestaurantCommand command)

Parameters

command CreateRestaurantCommand

Returns

Task < ActionResult <Restaurant\>\>

The created restaurant.

CreateRestaurantEvent\(Guid, CreateRestaurantEventCommand\)

Create an event in a restaurant.

[HttpPut("{restaurantGuid}/events")] [Authorize(Roles = "Admin, Owner")] [ProducesResponseType(typeof(Restaurant), 201)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(409)] [ProducesResponseType(500)] public Task<ActionResult<Restaurant>> CreateRestaurantEvent(Guid restaurantGuid, CreateRestaurantEventCommand command)

Parameters

restaurantGuid Guid

Guid of the restaurant.

command CreateRestaurantEventCommand

The command to create an event in a restaurant.

Returns

Task < ActionResult <Restaurant\>\>

The updated restaurant.

DeleteRestaurant\(Guid\)

Delete a restaurant by Guid.

[HttpDelete("{restaurantGuid}")] [Authorize(Roles = "Admin")] [ProducesResponseType(typeof(Restaurant), 204)] [ProducesResponseType(typeof(Restaurant), 400)] [ProducesResponseType(typeof(Restaurant), 401)] [ProducesResponseType(typeof(Restaurant), 403)] [ProducesResponseType(typeof(Restaurant), 404)] [ProducesResponseType(typeof(Restaurant), 500)] public Task<ActionResult> DeleteRestaurant(Guid restaurantGuid)

Parameters

restaurantGuid Guid

Guid of the restaurant to delete.

Returns

Task < ActionResult \>

A unit value that signify the success of the operation.

GetActiveMenu\(Guid, MenuStates\)

Get restaurant's menu by state.

[HttpGet("{restaurantGuid}/menus")] [ProducesResponseType(200)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<IEnumerable<Menu>>> GetActiveMenu(Guid restaurantGuid, MenuStates states = MenuStates.Active | MenuStates.Inactive)

Parameters

restaurantGuid Guid

Guid of the restaurant.

states MenuStates

The state of the menus to get.

Returns

Task < ActionResult < IEnumerable <Menu\>\>\>

GetAllRestaurants\(\)

Get all the restaurants.

[HttpGet] [Authorize(Roles = "Admin")] [ProducesResponseType(typeof(IEnumerable<Restaurant>), 200)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(500)] public Task<ActionResult<IEnumerable<Restaurant>>> GetAllRestaurants()

Returns

Task < ActionResult < IEnumerable <Restaurant\>\>\>

All restaurants.

GetRestaurantById\(Guid\)

Get a restaurant by Guid.

[HttpGet("{restaurantGuid}")] [ProducesResponseType(typeof(Restaurant), 200)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<RestaurantResponse>> GetRestaurantById(Guid restaurantGuid)

Parameters

restaurantGuid Guid

Guid of the restaurant to get.

Returns

Task < ActionResult <RestaurantResponse\>\>

The requested restaurant.

LinkRestaurantToStripe\(Guid, LinkRestaurantToBillingPlatformCommand\)

Create a Stripe account for the restaurant (Stripe Connect Express).

[HttpPut("{restaurantGuid}/stripe-linking")] [Authorize(Roles = "Admin, Owner")] [ProducesResponseType(typeof(RestaurantAccountResponse), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(409)] [ProducesResponseType(500)] public Task<ActionResult<RestaurantAccountResponse>> LinkRestaurantToStripe(Guid restaurantGuid, LinkRestaurantToBillingPlatformCommand command)

Parameters

restaurantGuid Guid

Guid of the restaurant to update.

command LinkRestaurantToBillingPlatformCommand

Command that contain the infos to update on the restaurant.

Returns

Task < ActionResult <RestaurantAccountResponse\>\>

RemoveMenu\(Guid, Guid\)

Remove a menu from a restaurant.

[HttpDelete("{restaurantGuid}/menus/{menuGuid}")] [Authorize(Roles = "Admin")] [ProducesResponseType(204)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<Restaurant>> RemoveMenu(Guid restaurantGuid, Guid menuGuid)

Parameters

restaurantGuid Guid

Guid of the restaurant.

menuGuid Guid

Guid of the menu.

Returns

Task < ActionResult <Restaurant\>\>

A unit value that signify a no content success response.

Create a Stripe account for the restaurant (Stripe Connect Express).

[HttpPut("{restaurantGuid}/renew-stripe-account-link")] [Authorize(Roles = "Admin, Owner")] [ProducesResponseType(typeof(RestaurantAccountResponse), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<RestaurantAccountResponse>> RenewStripeAccountLink(Guid restaurantGuid, RenewRestaurantAccountLinkCommand command)

Parameters

restaurantGuid Guid

Guid of the restaurant to update.

command RenewRestaurantAccountLinkCommand

Command that contain the infos to update on the restaurant.

Returns

Task < ActionResult <RestaurantAccountResponse\>\>

StripeExpressDashboardRedirection\(Guid, RestaurantStripeDashboardRedirectCommand\)

Create a Stripe account redirection the restaurant (Stripe Connect Express).

[HttpPost("{restaurantGuid}/stripe-express-dashboard")] [Authorize(Roles = "Admin, Owner")] [ProducesResponseType(typeof(RestaurantAccountResponse), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<RestaurantAccountResponse>> StripeExpressDashboardRedirection(Guid restaurantGuid, RestaurantStripeDashboardRedirectCommand command)

Parameters

restaurantGuid Guid

Guid of the restaurant to redirect to express dashboard.

command RestaurantStripeDashboardRedirectCommand

Command that contain the infos to generate the express link.

Returns

Task < ActionResult <RestaurantAccountResponse\>\>

ToggleActiveMenu\(Guid, Guid\)

Toggle the state of a restaurant menu.

[HttpPost("{restaurantGuid}/menus/{menuGuid}/toggle")] [Authorize(Roles = "Admin, Owner")] [ProducesResponseType(typeof(Restaurant), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<Restaurant>> ToggleActiveMenu(Guid restaurantGuid, Guid menuGuid)

Parameters

restaurantGuid Guid

Guid of the restaurant.

menuGuid Guid

Guid of the menu.

Returns

Task < ActionResult <Restaurant\>\>

The updated restaurant.

TogglePaymentMode\(Guid\)

Toggle the state of a restaurant payment mode.

[HttpPost("{restaurantGuid}/payment-mode/toggle")] [Authorize(Roles = "Admin, Owner")] [ProducesResponseType(typeof(Restaurant), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<Restaurant>> TogglePaymentMode(Guid restaurantGuid)

Parameters

restaurantGuid Guid

Guid of the restaurant.

Returns

Task < ActionResult <Restaurant\>\>

The updated restaurant.

UpdateProductImage\(Guid, UpdateRestaurantImageCommand\)

Update a restaurant image.

[HttpPut("{restaurantGuid}/image")] [Authorize(Roles = "Admin, Owner")] [ProducesResponseType(typeof(Unit), 204)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(500)] public Task<ActionResult<Unit>> UpdateProductImage(Guid restaurantGuid, UpdateRestaurantImageCommand command)

Parameters

restaurantGuid Guid

Guid of the restaurant to update.

command UpdateRestaurantImageCommand

Command from the body that contains the Img url.

Returns

Task < ActionResult <Unit\>\>

UpdateRestaurant\(Guid, UpdateRestaurantCommand\)

Update a restaurant by Guid.

[HttpPut("{restaurantGuid}")] [Authorize(Roles = "Admin, Owner")] [ProducesResponseType(typeof(Restaurant), 200)] [ProducesResponseType(400)] [ProducesResponseType(401)] [ProducesResponseType(403)] [ProducesResponseType(404)] [ProducesResponseType(409)] [ProducesResponseType(500)] public Task<ActionResult<Restaurant>> UpdateRestaurant(Guid restaurantGuid, UpdateRestaurantCommand command)

Parameters

restaurantGuid Guid

Guid of the restaurant to update.

command UpdateRestaurantCommand

Command that contain the infos to update on the restaurant.

Returns

Task < ActionResult <Restaurant\>\>

The updated restaurant.

Last modified: 21 May 2024