File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
LibraryManagement.Api/Controllers Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -135,5 +135,43 @@ public async ValueTask<ActionResult<Book>> PutBookAsync(Book book)
135135 return InternalServerError ( bookServiceException . InnerException ) ;
136136 }
137137 }
138+
139+ [ HttpDelete ]
140+ public async ValueTask < ActionResult < Book > > DeleteBookAsync ( Guid bookId )
141+ {
142+ try
143+ {
144+ Book deleteBook =
145+ await this . bookService . RemoveBookByIdAsync ( bookId ) ;
146+
147+ return Ok ( deleteBook ) ;
148+ }
149+ catch ( BookValidationException bookValidationException )
150+ when ( bookValidationException . InnerException is NotFoundBookException )
151+ {
152+ return NotFound ( bookValidationException . InnerException ) ;
153+ }
154+ catch ( BookValidationException bookValidationException )
155+ {
156+ return BadRequest ( bookValidationException . InnerException ) ;
157+ }
158+ catch ( BookDependencyValidationException bookDependencyValidationException )
159+ when ( bookDependencyValidationException . InnerException is LockedBookException )
160+ {
161+ return Locked ( bookDependencyValidationException . InnerException ) ;
162+ }
163+ catch ( BookDependencyValidationException bookDependencyValidationException )
164+ {
165+ return BadRequest ( bookDependencyValidationException . InnerException ) ;
166+ }
167+ catch ( BookDependencyException bookDependencyException )
168+ {
169+ return InternalServerError ( bookDependencyException . InnerException ) ;
170+ }
171+ catch ( BookServiceException bookServiceException )
172+ {
173+ return InternalServerError ( bookServiceException . InnerException ) ;
174+ }
175+ }
138176 }
139177}
You can’t perform that action at this time.
0 commit comments