- 🆒 C#
- 🥅 .NET
- 💽 MySql
- 🎞 Entity Framework
- 🕺 Swagger
Blind Cat Rescue takes in all types of animals, but has a soft spot for blind cats. Use this API to access their inventory of current adoptable animals.
- .NET 5 SDK
- A text editor like VS Code
- A command line interface like Terminal or GitBash to run and interact with the console app.
- MySQL Community Server
- Clone the repository:
$ git clone {https://github.com/JesseDWhite/AnimalShelter.Solution}
- Navigate to the
{AnimalShelter.Solution}
directory on your computer - Open with your preferred text editor to view the code base
- To setup a SQL database using MySQL:
- Create an
appsettings.json
file in the{AnimalShelter}
directory - Copy the text box below and paste into the
appsettings.json
file, replacing<password>
with your MySQL password:
"Logging": { "LogLevel": { "Default": "Warning", "System": "Information", "Microsoft": "Information" } }, { "ConnectionStrings": { "DefaultConnection": "Server=localhost;Port=3306;database=jesse_white;uid=root;pwd=<password>;" } }
- Open your terminal and run the command:
mysql -uroot -p<mysql_password>
(replace<mysql_password>
with your MySQL password) and select the enter key to launch MySQL servers
- Create an
- To run the console app:
- Navigate to
{AnimalShelter.Solution/AnimalShelter}
in your command line- Run the commands:
dotnet restore
to restore the dependencies that are listed in{AnimalShelter.csproj}
dotnet ef migrations add Initial
anddotnet 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 console app
- Run the commands:
- Visit the application via web browser at:
http://localhost:5004/
To access the Swagger Documentation for API calls for GET, PUT, and POST please see below:
- Run the application within
{AnimalShelter.Solution/AnimalShelter}
in your command line. - Once the application is running access the swagger documentation for API calls, go to
http://localhost:5004/index.html
- You can also follow this link while the program is running Swagger.
-
GET
/api/animals
- Returns all instances of Animal
-
GET
/api/animals/{id}
- Returns a single instance of Animal
-
POST
/api/animals
- Creates a new instance of Animal
-
PUT
/api/animals/{id}
- Edit an exsisting Animal
-
DELETE
/api/animals/{id}
- Remove an exsisting Animal from the API
http://localhost:5004/?animalName=biscuit&animalType=female&age=10
[
{
"AnimalId": 1,
"AnimalName": "Biscuit",
"AnimalType": "Cat",
"Gender": "Female",
"Age": 10,
"Description": "Loves long walks on the beach... and biscuits."
}
]
- Get random animal route does not work yet.
MIT © Jesse White 2021
Jesse White jesse.white6@gmail.com