An API that allows users to View, Add, Edit, and Delete cats and dogs from an imaginary Animal Shelter's archive. A user may interact with the in-use version of the API using Postman or the built-in Swagger UI. Additionally, users may download the corresponding Animal Shelter Client web application here
- .NET 5 SDK
- A text editor like VS Code
- A command line interface like Terminal or GitBash to run and interact with the app.
- MySQL Workbench
- (Optional)Postman
- Clone the repository:
$ git clone https://github.com/RyanDanielWalker/AnimalShelterAPI.Solution
- Navigate to the
AnimalShelterAPI.Solution/
directory on your computer - Open with your preferred text editor to view the code base
- In the production folder
AnimalShelterAPI.Solution/AnimalShelterAPI
create a file calledappsettings.json
- Add the following code:
{
"Logging": {
"LogLevel": {
"Default": "Warning",
"System": "Information",
"Microsoft": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server={YOUR_SERVER};Port={YOUR_PORT};database={YOUR_SCHEMA_NAME};uid=root;pwd={YOUR_PASSWORD};"
}
}
- Fill in the desired name of your server, port, schema and MySQL Workbench password, omitting the curly braces
- Navigate to
AnimalShelterAPI.Solution/AnimalShelterAPI
in your command line - Run the command
dotnet restore
to restore the dependencies that are listed in the .csproj - Run the command
dotnet build
to build the project and its dependencies into a set of binaries - Run the command
dotnet ef database update
to create database and populate tables - If you wish to update the database with any changes to the code, run the command
dotnet ef migrations add {MigrationName}
and againdotnet ef database update
- Finally, run the command
dotnet run
to run the project! - Note:
dotnet run
also restores and builds the project, so you can use this single command to start the app
- Download the corresponding Animal Shelter API client web application here
- After launching the project with
dotnet run
gain access to the API with Swagger by visitinglocalhost:5000/swagger
- Explore API endpoints using Postman
Request URL https://localhost:5000
GET /api/cats
POST /api/cats
GET /api/cats/{id}
PUT /api/cats/{id}
DELETE /api/cats/{id}
https://localhost:5001/api/Cats?name=doug
{
"catId": 1,
"name": "Doug",
"age": 4,
"gender": "Male",
"description": "Lovely"
}
GET /api/dogs
POST /api/dogs
GET /api/dogs/{id}
PUT /api/dogs/{id}
DELETE /api/dogs/{id}
https://localhost:5001/api/Dogs?name=emma
{
"dogId": 5,
"name": "Emma",
"age": 18,
"gender": "Female",
"description": "Lovely"
}
There were no bugs found
- ASP .NET Core MVC
- C#
- VS Code
- MySQL Workbench
- MySQL
- Entity Framework Core
- LINQ
- Swagger
- Swashbuckle.AspNetCore
- Postman
- AspNetCore Mvc Versioning
MIT
Copyright (c) 2021 Ryan Walker