Skip to content

Commit 90a4197

Browse files
Merge pull request #71 from DilmurodDeveloper/users/DilmurodDeveloper/exposers-readerbook-get
EXPOSERS: Get ReaderBook By Reader Id
2 parents dffe92b + e3f4ec8 commit 90a4197

File tree

4 files changed

+40
-19
lines changed

4 files changed

+40
-19
lines changed

LibraryManagement.Api/Controllers/HomeController.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//-----------------------------------------------------------
2+
// Copyright (c) Coalition of Good-Hearted Engineers
3+
// Free To Use To Build Reliable Library Management Solutions
4+
//-----------------------------------------------------------
5+
6+
using LibraryManagement.Api.Models.Foundations.ReaderBooks;
7+
using LibraryManagement.Api.Services.Foundations.ReaderBooks;
8+
using Microsoft.AspNetCore.Mvc;
9+
using RESTFulSense.Controllers;
10+
11+
namespace LibraryManagement.Api.Controllers
12+
{
13+
[ApiController]
14+
[Route("api/[controller]")]
15+
public class ReaderBooksController : RESTFulController
16+
{
17+
private readonly IReaderBookService readerBookService;
18+
19+
public ReaderBooksController(IReaderBookService readerBookService) =>
20+
this.readerBookService = readerBookService;
21+
22+
[HttpGet("{readerId}")]
23+
public async ValueTask<ActionResult<ReaderBook>> GetReaderBookByIdAsync(Guid readerId)
24+
{
25+
try
26+
{
27+
ReaderBook readerBook =
28+
await this.readerBookService.RetrieveReaderBookByIdAsync(readerId);
29+
30+
return Ok(readerBook);
31+
}
32+
catch (Exception exception)
33+
{
34+
return StatusCode(500, exception.Message);
35+
}
36+
}
37+
}
38+
}

LibraryManagement.Api/Models/Foundations/Books/Book.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public class Book
1414
public string BookTitle { get; set; }
1515
public string Author { get; set; }
1616
public string Genre { get; set; }
17-
[JsonIgnore]
1817
public Guid? ReaderId { get; set; }
1918
[JsonIgnore]
2019
public Reader? Reader { get; set; }

LibraryManagement.Api/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using LibraryManagement.Api.Brokers.Loggings;
77
using LibraryManagement.Api.Brokers.Storages;
88
using LibraryManagement.Api.Services.Foundations.Books;
9+
using LibraryManagement.Api.Services.Foundations.ReaderBooks;
910
using LibraryManagement.Api.Services.Foundations.Readers;
1011
using Microsoft.OpenApi.Models;
1112

@@ -22,6 +23,7 @@
2223
builder.Services.AddTransient<ILoggingBroker, LoggingBroker>();
2324
builder.Services.AddTransient<IBookService, BookService>();
2425
builder.Services.AddTransient<IReaderService, ReaderService>();
26+
builder.Services.AddTransient<IReaderBookService, ReaderBookService>();
2527
builder.Services.AddControllers();
2628
builder.Services.AddEndpointsApiExplorer();
2729

0 commit comments

Comments
 (0)