File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
LibraryManagement.Api/Controllers Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments