Skip to content

Commit 03a4dcb

Browse files
Merge pull request #37 from DilmurodDeveloper/users/DilmurodDeveloper/exposers-book-put
EXPOSERS: Put Book
2 parents 4a22b8f + 71def84 commit 03a4dcb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

LibraryManagement.Api/Controllers/BooksController.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,38 @@ public async ValueTask<ActionResult<Book>> GetBookByIdAsync(Guid bookId)
102102
return InternalServerError(bookServiceException.InnerException);
103103
}
104104
}
105+
106+
[HttpPut]
107+
public async ValueTask<ActionResult<Book>> PutBookAsync(Book book)
108+
{
109+
try
110+
{
111+
Book modifyBook =
112+
await this.bookService.ModifyBookAsync(book);
113+
114+
return Ok(modifyBook);
115+
}
116+
catch (BookValidationException bookValidationException)
117+
when (bookValidationException.InnerException is NotFoundBookException)
118+
{
119+
return NotFound(bookValidationException.InnerException);
120+
}
121+
catch (BookValidationException bookValidationException)
122+
{
123+
return BadRequest(bookValidationException.InnerException);
124+
}
125+
catch (BookDependencyValidationException bookDependencyValidationException)
126+
{
127+
return Conflict(bookDependencyValidationException.InnerException);
128+
}
129+
catch (BookDependencyException bookDependencyException)
130+
{
131+
return InternalServerError(bookDependencyException.InnerException);
132+
}
133+
catch (BookServiceException bookServiceException)
134+
{
135+
return InternalServerError(bookServiceException.InnerException);
136+
}
137+
}
105138
}
106139
}

0 commit comments

Comments
 (0)