An API project that allows users to Create, Read, Update, and Delete animals and lists the available animals at the shelter.
- A user is able to GET (read) a list of animals.
- A user is able to GET a specific animal information based on AnimalId.
- A user is able to GET animals by type, age or gender.
- A user is able to POST (create) a new animal in the database.
- A user is able to PUT (update) an existing animal information in the database.
- A user is able to DELETE an existing animal information in the database.
- A user is able to GET a random animal information.
Only accepts requests that specify a version number (v1).
GET /animals/
http://localhost:5000/api/v1/animals/
{
"animalId": 1,
"name": "Alfie",
"type": "Cat",
"age": 7,
"gender": "Male"
},
{
"animalId": 2,
"name": "Cheetah",
"type": "Cat",
"age": 6,
"gender": "Female"
}
GET /animals/id
http://localhost:5000/api/v1/animals/1
{
"animalId": 1,
"name": "Alfie",
"type": "Cat",
"age": 7,
"gender": "Male"
}
GET /animals/id
http://localhost:5000/api/v1/animals?type=cat&age=6&gender=female
{
"animalId": 2,
"name": "Cheetah",
"type": "Cat",
"age": 6,
"gender": "Female"
}
POST /animal/
http://localhost:5000/api/v1/animals
{
"animalId": 3,
"name": "Spike",
"type": "Ferret",
"age": 2,
"gender": "Female"
}
PUT /thing/id
PUT http://localhost:5000/api/v1/animals/3
{
"animalId": 3,
"name": "Spike",
"type": "Ferret",
"age": 3,
"gender": "Male"
}
DELETE /animals/id
DELETE http://localhost:5000/api/v1/animal/3
Status: 200 OK
GET /animals/random
http://localhost:5000/api/v1/animals/random
{
"animalId": 5,
"name": "Leila",
"type": "Dog",
"age": 2,
"gender": "Female"
}
GET /animals/id
http://localhost:5000/api/v1/animals/9999
Status: 204 No Content
This application is equipped with Swagger. To testing this API, go to "http://localhost:5000/swagger/index.html" in your browser while running the application. (apiVersion (1) is required.)
- Download the .NET Core SDK Software Development Kit
- Open the .Net Core SDK file and install
- To confirm installation was successful, run the
$ dotnet --version
command in your terminal
_Download the MySQL Community Server DMG File MySQL Community Server page.
-
Follow along with the installer until you reach the configuration page. Once you've reached Configuration, set the following options (or user default if not specified):_ * use legacy password encryption * set password * click finish
-
Verify MySQL installation by opening Terminal and entering the command
mysql -uroot -p{your password here}
.
You can exit the mysql program by entering exit.
_Download MySQL Workbench DMG file MySQL Workbench page.
- Install MySQL Workbench to Applications folder.
- Open MySQL Workbench and select Local instance 3306 server, then enter the password you set. If it connects, you're all set._
_Download the MySQL Web Installer MySQL Web Installer
- Choose Custom setup type
- When prompted to Select Products and Features, choose the following:
- MySQL Server (Will be under MySQL Servers)
- MySQL Workbench (Will be under Applications)
- Select Next, then Execute. Wait for download and installation
- Advance through Configuration as follows:
- High Availability set to Standalone.
- Defaults are OK under Type and Networking.
- Authentication Method set to Use Legacy Authentication Method.
- Set password to epicodus. You can use your own if you want but epicodus will be assumed in the lessons.
- Unselect Configure MySQL Server as a Windows Service.
- Complete installation process
Add the MySQL environment variable to the System PATH. Instructions for Windows 10:
- Open the Control Panel and visit System > Advanced System Settings > Environment Variables...
- Select PATH..., click Edit..., then Add.
- Add the exact location of your MySQL installation and click OK. (This location is likely C:\Program Files\MySQL\MySQL Server 8.0\bin, but may differ depending on your specific installation.)
- Verify installation by opening Windows PowerShell and entering the command
mysql -uroot -p{your password here}
. It's working correctly if you gain access to the MySQL command line. You can exit the mysql program by enteringexit
Download Manually:
- Navigate to https://github.com/fc-dogan/AnimalShelterAPI
- Click the green "Clone or Download" button.
- Click "Download ZIP".
- Click downloaded file to unzip.
- Open folder (AnimalShelterAPI).
In Terminal:
-
Navigate to where you want this application to be saved, i.e.:
cd desktop
-
Clone the file from GitHub with HTTPS
git clone https://github.com/fc-dogan/AnimalShelterAPI
-
Open file in your preferred text editor
cd AnimalShelterAPI
-
Change directories into the project directory
cd AnimalShelterAPI/AnimalShelter
-
Restore all dependencies
dotnet restore
-
Build the project and dependencies
dotnet build
- Build the database
dotnet ef database update
To run this application:
-
Run the program
dotnet run
Note: To exit, simply press
Ctrl + C
-
access the Swagger UI for testing this API
No known bugs at this time.
- C#
- .Net Core 2.2
- ASP.NET Core MVC
- MySQL, MySQL Workbench
- Entity Framework Core 2.2
- ASP.NET Core Razor 2.2
- RestSharp
- Newtonsoft.Json
- ASP.NET Core Mvc Versioning 3.1.1
- Swagger
- NSwag ASP.NET Core 13.3.0
Copyright (c) 2020 Fatma C. Dogan