Skip to content

Commit 620d787

Browse files
Merge pull request #67 from DilmurodDeveloper/users/DilmurodDeveloper/exposers-reader-delete
EXPOSERS: Delete Reader
2 parents 20d1840 + 2e77bc3 commit 620d787

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

LibraryManagement.Api/Controllers/ReadersController.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,43 @@ public async ValueTask<ActionResult<Reader>> PutReaderAsync(Reader reader)
137137
return InternalServerError(readerServiceException.InnerException);
138138
}
139139
}
140+
141+
[HttpDelete]
142+
public async ValueTask<ActionResult<Reader>> DeleteReaderAsync(Guid readerId)
143+
{
144+
try
145+
{
146+
Reader deleteReader =
147+
await this.readerService.RemoveReaderByIdAsync(readerId);
148+
149+
return Ok(deleteReader);
150+
}
151+
catch (ReaderValidationException readerValidationException)
152+
when (readerValidationException.InnerException is NotFoundReaderException)
153+
{
154+
return NotFound(readerValidationException.InnerException);
155+
}
156+
catch (ReaderValidationException readerValidationException)
157+
{
158+
return BadRequest(readerValidationException.InnerException);
159+
}
160+
catch (ReaderDependencyValidationException readerDependencyValidationException)
161+
when (readerDependencyValidationException.InnerException is LockedReaderException)
162+
{
163+
return Locked(readerDependencyValidationException.InnerException);
164+
}
165+
catch (ReaderDependencyValidationException readerDependencyValidationException)
166+
{
167+
return BadRequest(readerDependencyValidationException.InnerException);
168+
}
169+
catch (ReaderDependencyException readerDependencyException)
170+
{
171+
return InternalServerError(readerDependencyException.InnerException);
172+
}
173+
catch (ReaderServiceException readerServiceException)
174+
{
175+
return InternalServerError(readerServiceException.InnerException);
176+
}
177+
}
140178
}
141179
}

0 commit comments

Comments
 (0)