Closed mdewey closed 5 years ago
We are taking a surprise trip to the Savannah for a safari to see all sorts of exotic animals. During our time there we want to keep track of all the animals we have seen. For this, we need to create an API to help record what we see.
[x] Your database will be named called SafariVacation / safari_vacation
SafariVacation
safari_vacation
SeenAnimals
seen_animals
Id
id
Species
species
CountOfTimesSeen
count_of_times_seen
LocationOfLastSeen
location_of_last_seen
pgcli
[x] Your API should have the following endpoints:
GET /Animals
GET /Search?species=lion
POST /Animal
GET /Animal/{location}
PUT /Animal/{animal}
DELETE /Animal/{animal}
NOTES:
Location
Search
PUT /Animal/{animal}/{amount}
{amount}
Here are the interesting commands you will need for tonight's assignment
To add Entity Framework to your project:
dotnet add package Microsoft.EntityFrameworkCore.Design --version 2.1.3 dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version 2.1.2
To create your database:
createdb <<DatabaseName>>
To create the DbContext
dotnet ef dbcontext scaffold "server=localhost;database=<<DatabaseName>>" Npgsql.EntityFrameworkCore.PostgreSQL -c <<DatabaseName>>Context
- Add a migration:
dotnet ef migrations add AddBaordGameTable
- Update your database
dotnet ef database update
- Documentation: [Dotnet EF CLI Docs](https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet)
https://github.com/mrected/safari-vacation
Your homework was marked: Meets Expectations
“Well done!” — via Gavin Stark
Let's Continue our safari adventure
We are taking a surprise trip to the Savannah for a safari to see all sorts of exotic animals. During our time there we want to keep track of all the animals we have seen. For this, we need to create an API to help record what we see.
Objectives
Requirements
Explorer Mode
[x] Your database will be named called
SafariVacation
/safari_vacation
SeenAnimals
/seen_animals
that has the following columnsId
/id
(int)Species
/species
(string)CountOfTimesSeen
/count_of_times_seen
(int)LocationOfLastSeen
/location_of_last_seen
(string)pgcli
.[x] Your API should have the following endpoints:
GET /Animals
Endpoint that returns all animals you have seenGET /Search?species=lion
that returns all animals where the species name contains the title parameterPOST /Animal
endpoints that adds a movie to the database. This should take a JSON bodyGET /Animal/{location}
that returns animals of only that locationPUT /Animal/{animal}
endpoint that adds 1 to that animalDELETE /Animal/{animal}
endpoint that deletes that animal from the databaseNOTES:
Adventure Mode
Location
be its own tableSearch
endpoint to search by animal or by locationPUT /Animal/{animal}/{amount}
endpoint that adds{amount}
to that animalEpic Mode
Additional Resources
.NET
Here are the interesting commands you will need for tonight's assignment
To add Entity Framework to your project:
To create your database:
To create the DbContext
dotnet ef migrations add AddBaordGameTable
dotnet ef database update