mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 20:01:10 +00:00
Adds skeleton Books controller.
This commit is contained in:
1 parent
75cce8bfb9
commit
84229a5f1e
2 files changed
+63
No files matched your search
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Controller for managing books.
|
||||
/// </summary>
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
public class BooksController : ApiController
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
private readonly ISender mediator;
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BooksController"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediator">Injecting service for mediating commands and queries.</param>
|
||||
public BooksController(ISender mediator)
|
||||
{
|
||||
this.mediator = mediator;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Gets all books.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="ErrorOr{T}"/> containing either a collection of books, or an error.</returns>
|
||||
[HttpGet()]
|
||||
public async Task<IActionResult> GetBooks()
|
||||
{
|
||||
// ErrorOr<IEnumerable<BookDto>> result = await mediator.Send(new GetBooksQuery());
|
||||
// return result.Match(result => Ok(result), errors => Problem(errors));
|
||||
return Ok(new List<string> { "Book 1", "Book 2", "Book 3" });
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Adds a book.
|
||||
// /// </summary>
|
||||
// /// <param name="command"></param>
|
||||
// /// <returns>The result of the HTTP request.</returns>
|
||||
// public async Task<IActionResult> AddBook(AddBookCommand command)
|
||||
// {
|
||||
// ErrorOr<Unit> result = await mediator.Send(command);
|
||||
// return result.Match(result => Ok(result), errors => Problem(errors));
|
||||
// }
|
||||
#endregion
|
||||
}
|
||||
@@ -8,6 +8,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mediator.Abstractions" Version="2.1.7" />
|
||||
<PackageReference Include="Mediator.SourceGenerator" Version="2.1.7">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in new issue
Block a user