Skip to content

wowgr8/ParksApi.Solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 

Repository files navigation

State And National Parks API

By Cesar Lopez

April 22, 2022

An ASP.NET Core web API for U.S. State and National Parks.

Table of Contents

  1. Technologies Used
  2. Description
  3. Setup/Installation Requirements
  4. API Info/Endpoints
  5. Known Bugs
  6. License
  7. Contact Information

Technologies Used

  • C#
  • .NET 5.0
  • ASP.Net Core
  • ASP.NET MVC
  • Dotnet ef
  • Sql
  • MySql Workbench
  • Visual Studio Code
  • Entity Framework Core
  • Postman
  • Swagger
  • Swashbuckle

Description

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.

Setup/Installation Requirements

  1. Make sure you have MySql Workbench installed.

  2. Make sure to have dotnet-ef installed too.
    This project uses dotnet-ef --version 5.0.0 which I have globally installed but you can install it however you want.

  3. Download .NET 5.0 SDK for : Windows or Mac.

  4. Clone the appliction to your computer by entering: git clone https://github.com/wowgr8/https://github.com/ParksApi.Solution in the terminal.

  5. Open the repository in the terminal and cd into the Parks directory.

  6. Create a new file by entering touch appsettings.json in the root directory

  7. 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];"
  }
}
  1. Run dotnet build on the command line to check for errors.
  2. Launch MySql Workbench
  3. 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.
  4. Next run dotnet ef database update to 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.
  5. Run dotnet build again to ensure there are no errors.
  6. Once everything builds successfully, enter dotnet run on the command line to start the StateAndNatParks API.

API Info/Endpoints

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:
    click for image
https://localhost:5001/api/StateAndNatParks


 

  • Listing/Editing/Deleting a park by id:
    click for image
https://localhost:5001/api/StateAndNatParks/4


 

  • Searching by parameter:
    click for image
https://localhost:5001/api/StateAndNatParks?type=State%20Park


 

Known Bugs

  • No known issues

License

MIT License Published 2022 by Cesar Lopez

Contact Information

If you encounter any issues or have any questions or ideas for this site, please contact:

Cesar Lopez:

About

An ASP.NET Core web API for U.S. State and National Parks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages