From 5e783be955fab1976eeb874fe607047896c16c04 Mon Sep 17 00:00:00 2001 From: DilmurodDeveloper Date: Mon, 21 Jul 2025 16:37:18 +0500 Subject: [PATCH 1/2] EXPOSERS: Get All Readers --- .../Controllers/ReadersController.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/LibraryManagement.Api/Controllers/ReadersController.cs b/LibraryManagement.Api/Controllers/ReadersController.cs index e2ad32c..ca84ff7 100644 --- a/LibraryManagement.Api/Controllers/ReadersController.cs +++ b/LibraryManagement.Api/Controllers/ReadersController.cs @@ -54,5 +54,25 @@ public async ValueTask> PostReaderAsync(Reader reader) return InternalServerError(readerServiceException.InnerException); } } + + [HttpGet("all")] + public ActionResult> GetAllReaders() + { + try + { + IQueryable allReaders = + this.readerService.RetrieveAllReaders(); + + return Ok(allReaders); + } + catch (ReaderDependencyException readerDependencyException) + { + return InternalServerError(readerDependencyException.InnerException); + } + catch (ReaderServiceException readerServiceException) + { + return InternalServerError(readerServiceException.InnerException); + } + } } } From c202b3ef6f5e84e2678401fc1cb4b037ebe4dc6f Mon Sep 17 00:00:00 2001 From: DilmurodDeveloper Date: Mon, 21 Jul 2025 16:41:04 +0500 Subject: [PATCH 2/2] EXPOSERS: Get Reader ById --- .../Controllers/ReadersController.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/LibraryManagement.Api/Controllers/ReadersController.cs b/LibraryManagement.Api/Controllers/ReadersController.cs index ca84ff7..798cbe9 100644 --- a/LibraryManagement.Api/Controllers/ReadersController.cs +++ b/LibraryManagement.Api/Controllers/ReadersController.cs @@ -74,5 +74,35 @@ public ActionResult> GetAllReaders() return InternalServerError(readerServiceException.InnerException); } } + + [HttpGet("{readerId}")] + public async ValueTask> GetReaderByIdAsync(Guid readerId) + { + try + { + Reader getReaderById = + await this.readerService.RetrieveReaderByIdAsync(readerId); + + return Ok(getReaderById); + } + catch (ReaderValidationException readerValidationException) + when (readerValidationException.InnerException is InvalidReaderException) + { + return BadRequest(readerValidationException.InnerException); + } + catch (ReaderValidationException readerValidationException) + when (readerValidationException.InnerException is NotFoundReaderException) + { + return NotFound(readerValidationException.InnerException); + } + catch (ReaderDependencyException readerDependencyException) + { + return InternalServerError(readerDependencyException.InnerException); + } + catch (ReaderServiceException readerServiceException) + { + return InternalServerError(readerServiceException.InnerException); + } + } } }