Skip to content

Commit c202b3e

Browse files
EXPOSERS: Get Reader ById
1 parent 5e783be commit c202b3e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

LibraryManagement.Api/Controllers/ReadersController.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,35 @@ public ActionResult<IQueryable<Reader>> GetAllReaders()
7474
return InternalServerError(readerServiceException.InnerException);
7575
}
7676
}
77+
78+
[HttpGet("{readerId}")]
79+
public async ValueTask<ActionResult<Reader>> GetReaderByIdAsync(Guid readerId)
80+
{
81+
try
82+
{
83+
Reader getReaderById =
84+
await this.readerService.RetrieveReaderByIdAsync(readerId);
85+
86+
return Ok(getReaderById);
87+
}
88+
catch (ReaderValidationException readerValidationException)
89+
when (readerValidationException.InnerException is InvalidReaderException)
90+
{
91+
return BadRequest(readerValidationException.InnerException);
92+
}
93+
catch (ReaderValidationException readerValidationException)
94+
when (readerValidationException.InnerException is NotFoundReaderException)
95+
{
96+
return NotFound(readerValidationException.InnerException);
97+
}
98+
catch (ReaderDependencyException readerDependencyException)
99+
{
100+
return InternalServerError(readerDependencyException.InnerException);
101+
}
102+
catch (ReaderServiceException readerServiceException)
103+
{
104+
return InternalServerError(readerServiceException.InnerException);
105+
}
106+
}
77107
}
78108
}

0 commit comments

Comments
 (0)