A solution I developed in 2015 to get a feel of Web API 2 with Entity Framework.
This uses the following technology...
- C#
- ASP.NET Web API 2
- Entity Framework 6 (using code first approach)
- JsonPatch
- SimpleInjector
- NUnit
- NSubsitute
- NBuilder
- FluentAssertions
Developed against localdb
Connection string can be found here
Database is seeded with test data, found here
##Setup Restore nuget packages
nuget install
Seed database by typing the following in Package Manager Console
Update-Database
Note: You can more information on seeding here
Replace placeholder {}
with actual value
http://localhost:{port}/api/library/books
http://localhost:{port}/api/library/books/3
http://localhost:{port}/api/library/authors/{author}/books
http://localhost:{port}/api/library/books
{
"Title": "Austrailia",
"Isbn": "66666",
"Author": {
"Id": 1,
"Name": "Amy Brown"
},
"Publisher": {
"Id": 1,
"Name": "O' Reilly"
}
}
http://localhost:{port}/api/library/books/{id}
[
{ "op": "replace", "path": "Title", "value": "Australia" }
]
More info about other patching operations can be found here
http://localhost:{port}/api/library/books/{id}
This repo would not be complete without the Dojocat...