Beast Rescue of the Pacific Northwest
Melissa Scmi
This API & companion MVC app allow users to browse, add to, & update the current animals living at Beast Rescue of the Pacific Northwest.
- C#
- NuGet
- .NET 5
- MySql
- ASP.NET Core
- Entity Framework
- Swagger
Setup & Use
- .NET 5 SDK
- A text editor like VS Code
- A command line interface like Terminal or GitBash
- MySql & MySql Workbench
-
Clone this repository to an empty folder or to your desktop, or download and open the Zip on your machine. Instructions for cloning can be found here.
-
Open the
BeastRescue.Solution
folder in your preferred text editor -
Set up a SQL database:
- Create a new
appsettings.json
file inBeastRescue.Solution/BeastRescue
- Copy the following code into that file, replacing
YOUR_PASSWORD
with your MySQL password:
"Logging": { "LogLevel": { "Default": "Warning", "System": "Information", "Microsoft": "Information" } }, { "ConnectionStrings": { "DefaultConnection": "Server=localhost;Port=3306;database=beast_rescue;uid=root;pwd=YOUR_PASSWORD;" } }
- Create a new
-
This repo includes database Migrations. To make use of those, simply run
dotnet ef database update
in yourBeastRescue.Solution/BeastRescue
directory. This will create a pre-populated database of animals. -
Restore and build the API project:
- Navigate to the
BeastRescue.Solution/BeastRescue
folder in the command line or terminal
-- Rundotnet restore
to restore the project dependencies
-- Rundotnet build
to build and compile the project
- Navigate to the
-
Use the API:
- Navigate to the
BeastRescue.Solution/BeastRescue
folder in the terminal - Run
dotnet run
- If you would like to be able to continue viewing results while making changes to content, instead run
dotnet watch run
- Navigate to the
-
Restore and build the MVC project:
- Navigate to the
BeastRescue.Solution/BeastRescueClient
folder in the command line or terminal
-- Rundotnet restore
to restore the project dependencies
-- Rundotnet build
to build and compile the project
- Navigate to the
-
Use the Web App:
- Navigate to the
BeastRescue.Solution/BeastRescueClient
folder in the terminal - Run
dotnet run
- If you would like to be able to continue viewing the site while making changes, instead run
dotnet watch run
- Access http://localhost:5003 in your web browser
- Look at the beasts! Imagine their lives! Yay.
- Navigate to the
Documentation and Routes
This project includes Swagger.
Per Epicodus, "Swagger is an open-source standardized and language-agnostic interface for designing and documenting REST APIs. It can be used to design APIs before they’re built or to document APIs after the code has already been implemented." see citation
To access Swagger Documentation for API calls GET, PATCH, and POST:
- Run the API application, as detailed above
- Once the application is running, go to
http://localhost:5000
-- You can also follow this link while the program is running: Beast Rescue Swagger
If you'd like to use the API manually, you can append the following routes to http://localhost:5000 in your browser or Postman
-
GET
/api/beasts
- Returns all beasts in database
-
GET
/api/beasts/{id}
- Returns a single beast with the specified ID
-
POST
/api/beasts
- Creates a new beast in the database
-
PUT
/api/beasts/{id}
- Edits the existing beast with the specified id
-
DELETE
/api/beasts/{id}
- Deletes the existing beast with the specified id
- None, really, but NB: only GET routes are set up for the MVC app.
GPL Copyright (c) 2021, Melissa Schatz-Miller
Melissa Schatz-Miller melissa.scmi@gmail.com
Please feel free to reach out to me with suggested changes/improvements, or if you have any questions.