Closed mdewey closed 6 years ago
We are taking a surprise trip to the Savannah for a safari to see all sorts of exotic animals. During our time their 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}
Location
Search
PUT /Animal/{animal}/{amount}
{amount}
Here are the interesting commands you will need for tonights assignment
To get the code gen tools
dotnet tool install --global dotnet-aspnet-codegenerator
To add Entity Framework to your project:
dotnet add package Microsoft.EntityFrameworkCore.Design dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
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)
explorer mode complete, https://github.com/benjaminkent/safari_vacation
Your homework was marked: Meets Expectations
“Ring that bell!” — via Mark Dewey
title: Take the Safari Online. draft: true
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 their 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 animal 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 databaseAdventure 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 tonights assignment
To get the code gen tools
To add Entity Framework to your project:
To create your database:
To create the DbContext
dotnet ef migrations add AddBaordGameTable
dotnet ef database update