Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions LibraryManagement.Api/Controllers/ReadersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,43 @@ public async ValueTask<ActionResult<Reader>> PutReaderAsync(Reader reader)
return InternalServerError(readerServiceException.InnerException);
}
}

[HttpDelete]
public async ValueTask<ActionResult<Reader>> DeleteReaderAsync(Guid readerId)
{
try
{
Reader deleteReader =
await this.readerService.RemoveReaderByIdAsync(readerId);

return Ok(deleteReader);
}
catch (ReaderValidationException readerValidationException)
when (readerValidationException.InnerException is NotFoundReaderException)
{
return NotFound(readerValidationException.InnerException);
}
catch (ReaderValidationException readerValidationException)
{
return BadRequest(readerValidationException.InnerException);
}
catch (ReaderDependencyValidationException readerDependencyValidationException)
when (readerDependencyValidationException.InnerException is LockedReaderException)
{
return Locked(readerDependencyValidationException.InnerException);
}
catch (ReaderDependencyValidationException readerDependencyValidationException)
{
return BadRequest(readerDependencyValidationException.InnerException);
}
catch (ReaderDependencyException readerDependencyException)
{
return InternalServerError(readerDependencyException.InnerException);
}
catch (ReaderServiceException readerServiceException)
{
return InternalServerError(readerServiceException.InnerException);
}
}
}
}
Loading