From 84229a5f1e2f95ee29ffdb301bc194a9052d43d9 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Fri, 23 Aug 2024 19:49:25 +0300 Subject: [PATCH] Adds skeleton Books controller. --- .../Controllers/Books/BooksController.cs | 56 +++++++++++++++++++ .../Lumina.Presentation.Api.csproj | 7 +++ 2 files changed, 63 insertions(+) create mode 100644 src/Lumina.Presentation.Api/Controllers/Books/BooksController.cs diff --git a/src/Lumina.Presentation.Api/Controllers/Books/BooksController.cs b/src/Lumina.Presentation.Api/Controllers/Books/BooksController.cs new file mode 100644 index 00000000..d03b41c4 --- /dev/null +++ b/src/Lumina.Presentation.Api/Controllers/Books/BooksController.cs @@ -0,0 +1,56 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Presentation.Api.Controllers.Common; +using Mediator; +using Microsoft.AspNetCore.Mvc; +#endregion + +namespace Lumina.Presentation.Api.Controllers.Books; + +/// +/// Controller for managing books. +/// +[ApiVersion("1.0")] +[Route("api/v{version:apiVersion}/[controller]")] +public class BooksController : ApiController +{ + #region ================================================================== FIELD MEMBERS ================================================================================ + private readonly ISender mediator; + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// Injecting service for mediating commands and queries. + public BooksController(ISender mediator) + { + this.mediator = mediator; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Gets all books. + /// + /// An containing either a collection of books, or an error. + [HttpGet()] + public async Task GetBooks() + { + // ErrorOr> result = await mediator.Send(new GetBooksQuery()); + // return result.Match(result => Ok(result), errors => Problem(errors)); + return Ok(new List { "Book 1", "Book 2", "Book 3" }); + } + + // /// + // /// Adds a book. + // /// + // /// + // /// The result of the HTTP request. + // public async Task AddBook(AddBookCommand command) + // { + // ErrorOr result = await mediator.Send(command); + // return result.Match(result => Ok(result), errors => Problem(errors)); + // } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj b/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj index 476fd11e..2462e4ed 100644 --- a/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj +++ b/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj @@ -8,6 +8,13 @@ + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + +