diff --git a/LibraryManagement.Api/Controllers/HomeController.cs b/LibraryManagement.Api/Controllers/HomeController.cs deleted file mode 100644 index 14a94b2..0000000 --- a/LibraryManagement.Api/Controllers/HomeController.cs +++ /dev/null @@ -1,18 +0,0 @@ -//----------------------------------------------------------- -// Copyright (c) Coalition of Good-Hearted Engineers -// Free To Use To Build Reliable Library Management Solutions -//----------------------------------------------------------- - -using Microsoft.AspNetCore.Mvc; -using RESTFulSense.Controllers; - -namespace LibraryManagement.Api.Controllers -{ - [ApiController] - [Route("api/[controller]")] - public class HomeController : RESTFulController - { - [HttpGet] - public IActionResult GetGreeting() => Ok("Hello, Library!"); - } -} diff --git a/LibraryManagement.Api/Controllers/ReaderBooksController.cs b/LibraryManagement.Api/Controllers/ReaderBooksController.cs new file mode 100644 index 0000000..9c517dd --- /dev/null +++ b/LibraryManagement.Api/Controllers/ReaderBooksController.cs @@ -0,0 +1,38 @@ +//----------------------------------------------------------- +// Copyright (c) Coalition of Good-Hearted Engineers +// Free To Use To Build Reliable Library Management Solutions +//----------------------------------------------------------- + +using LibraryManagement.Api.Models.Foundations.ReaderBooks; +using LibraryManagement.Api.Services.Foundations.ReaderBooks; +using Microsoft.AspNetCore.Mvc; +using RESTFulSense.Controllers; + +namespace LibraryManagement.Api.Controllers +{ + [ApiController] + [Route("api/[controller]")] + public class ReaderBooksController : RESTFulController + { + private readonly IReaderBookService readerBookService; + + public ReaderBooksController(IReaderBookService readerBookService) => + this.readerBookService = readerBookService; + + [HttpGet("{readerId}")] + public async ValueTask> GetReaderBookByIdAsync(Guid readerId) + { + try + { + ReaderBook readerBook = + await this.readerBookService.RetrieveReaderBookByIdAsync(readerId); + + return Ok(readerBook); + } + catch (Exception exception) + { + return StatusCode(500, exception.Message); + } + } + } +} diff --git a/LibraryManagement.Api/Models/Foundations/Books/Book.cs b/LibraryManagement.Api/Models/Foundations/Books/Book.cs index fb8ade7..4327657 100644 --- a/LibraryManagement.Api/Models/Foundations/Books/Book.cs +++ b/LibraryManagement.Api/Models/Foundations/Books/Book.cs @@ -14,7 +14,6 @@ public class Book public string BookTitle { get; set; } public string Author { get; set; } public string Genre { get; set; } - [JsonIgnore] public Guid? ReaderId { get; set; } [JsonIgnore] public Reader? Reader { get; set; } diff --git a/LibraryManagement.Api/Program.cs b/LibraryManagement.Api/Program.cs index 9612a2b..1b86f74 100644 --- a/LibraryManagement.Api/Program.cs +++ b/LibraryManagement.Api/Program.cs @@ -6,6 +6,7 @@ using LibraryManagement.Api.Brokers.Loggings; using LibraryManagement.Api.Brokers.Storages; using LibraryManagement.Api.Services.Foundations.Books; +using LibraryManagement.Api.Services.Foundations.ReaderBooks; using LibraryManagement.Api.Services.Foundations.Readers; using Microsoft.OpenApi.Models; @@ -22,6 +23,7 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer();