Hello! Here is little application with simple library model. I used here layered architecture to separate different parts of the app.
What did I use and implement here?
- Entity Framework Core with in-memory database.
- Fluent validator to validate incomming objects
- Middleware request logging
- Middleware error handling
- Custom Exceptions
- Explicity/Implicity methods to transform models to/from DTO instead of using automapper
- Seeding initial data for Database
- Hybrid Model Binding <https://www.nuget.org/packages/HybridModelBinding/0.18.1-alpha.5>
Here is what you can do with it:
GET https://{{baseUrl}}/api/books?order=author
//Response:
[{
"id": "number",
"reviewsNumber": "number", //count of reviews
"title": "string",
"author": "string",
"rating": "decimal", //average rating
}]
2. Get top 10 books with high rating and number of reviews greater than 10. You can filter books by specifying genre. Order by rating
GET https://{{baseUrl}}/api/recommended?genre=fantasy
//Response
[{
"id": "number",
"title": "string",
"author": "string",
"rating": "decimal", //average rating
"reviewsNumber": "number" //count of reviews
}]
GET https://{{baseUrl}}/api/books/{id}
//Response
{
"id": "number",
"title": "string",
"author": "string",
"cover": "string",
"content": "string",
"rating": "decimal", //average rating
"reviews": [{
"id": "number",
"message": "string",
"reviewer": "string",
}]
}
DELETE https://{{baseUrl}}/api/books/{id}?secret=qwerty
POST https://{{baseUrl}}/api/books/save
{
"id": "number", // if id is not provided creates a new book, otherwise - updates an existing one
"title": "string",
"cover": "string", // base64 image, but in reality just a dummy stirng))
"content": "string",
"genre": "string",
"author": "string"
}
// Response
{
"id": "number"
}
PUT https://{{baseUrl}}/api/books/{id}/review
{
"message": "string",
"reviewer": "string",
}
//Response
{
"id": "number"
}
PUT https://{{baseUrl}}/api/books/{id}/rate
{
"score": "number" // score can be from 1 to 5
}