Skip to content

Commit ddad2a7

Browse files
EXPOSERS: Get ReaderBook By Id
1 parent dffe92b commit ddad2a7

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
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+
}

0 commit comments

Comments
 (0)