- Technologies Used
- Description
- Setup/Installation Requirements
- API Info/Endpoints
- Known Bugs
- License
- Contact Information
- C#
- .NET 5.0
- ASP.Net Core
- ASP.NET MVC
- Dotnet ef
- Sql
- MySql Workbench
- Visual Studio Code
- Entity Framework Core
- Postman
- Swagger
- Swashbuckle
An ASP.NET Core web API for U.S. State and National Parks. The application is capable of the following:
- Getting a full list of state and national parks or via parameters.
- Getting a state or national park via Id.
- Adding state or national parks to the database.
- Editing a state or national park.
- Deleting a state or national park.
-
Make sure you have MySql Workbench installed.
-
Make sure to have dotnet-ef installed too.
This project usesdotnet-ef --version 5.0.0which I have globally installed but you can install it however you want. -
Clone the appliction to your computer by entering:
git clone https://github.com/wowgr8/https://github.com/ParksApi.Solutionin the terminal. -
Open the repository in the terminal and cd into the
Parksdirectory. -
Create a new file by entering
touch appsettings.jsonin the root directory -
Enter the following code below. Be sure to replace [Password] with the password for MySql workbench that you have set up. Do the same for [userid], the uid is the user id you've set up in MySql workbench.
{
"Logging": {
"LogLevel": {
"Default": "Warning",
"System": "Information",
"Microsoft": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Port=3306;database=parks_api;uid=root;pwd=[YOUR-PASSWORD-HERE];"
}
}
- Run
dotnet buildon the command line to check for errors. - Launch MySql Workbench
- Back in the terminal, run
dotnet ef migrations add Initial. Note: when making changes to the schema (i.e. making changes in the models that affect the database such as adding a new attribute, you would change "Initial" to something more descriptive of what change you are making to the table. - Next run
dotnet ef database updateto update the table. I've included values in the StateAndNatParkContext.cs file to seed the database with some state and national park entries for testing. - Run
dotnet buildagain to ensure there are no errors. - Once everything builds successfully, enter
dotnet runon the command line to start the StateAndNatParks API.
- Once the API is running, you can test the API endpoints on the index page: https://localhost:5001/index.html using Swagger.
The API enpoints are the following:
- GET /api/StateAndNatParks (returns a list of the state and national parks)
- POST /api/StateAndNatParks (allows user to add new park to the database)
- GET /api/StateAndNatParks/{id} (list an park by a specific id)
- PUT /api/StateAndNatParks/{id} (edit information about a specific park)
- DELETE /api/StateAndNatParks/{id} (delete a specific park by id)
Here are examples of available user queries:
- A full list of all the parks:
https://localhost:5001/api/StateAndNatParks
- Listing/Editing/Deleting a park by id:
https://localhost:5001/api/StateAndNatParks/4
- Searching by parameter:
https://localhost:5001/api/StateAndNatParks?type=State%20Park
- No known issues
MIT License Published 2022 by Cesar Lopez
If you encounter any issues or have any questions or ideas for this site, please contact:
Cesar Lopez:
- Email: Lopez.cesar.aug@gmail.com
- Github: wowgr8
- LinkedIn: https://www.linkedin.com/in/cesar-aug-lopez



