Skip to content

jessi-b/USParkApi.Solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation


|| US Park API ||
Epicodus - C# and .NET - Building an API - Code Review
___________________________
Jessi B
March 2022


Table of Contents


Description

An API that functions as a US Parks archive for national, state and city parks. It utilizes RESTful principles and version control. The user is able to see the in-use version of the API when using Postman.

Technologies Used

Setup & Installation

  dotnet add package Microsoft.EntityFrameworkCore -v 5.0.0
  dotnet add package Pomelo.EntityFrameworkCore.MySql -v 5.0.0-alpha.2
  dotnet add package Microsoft.EntityFrameworkCore.Design -v 5.0.0
  dotnet add USParkAPI.csproj package Swashbuckle.AspNetCore -v 6.2.3
  dotnet add package Microsoft.AspNetCore.Mvc.Versioning --version 5.0.0
  • Protect Your MySQL Password: Enter touch .gitignore & touch appsettings.json in the command line
  • Add the following code to appsettings.json & update the server, port, and user id & password as necessary:
    {
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft": "Warning",
          "Microsoft.Hosting.Lifetime": "Information"
        }
      },
      "AllowedHosts": "*",
      "ConnectionStrings": {
        "DefaultConnection": "Server=localhost;Port=3306;database=US_park;uid=root;pwd=YOUR PASSWORD;"
      }
    }
    
  • Add */appsettings.json to .gitignore
  • Update Database: Enter dotnet ef migrations add <MigrationName> & dotnet ef database update in the terminal
  • Install Dependecies: Enter dotnet restore in your terminal
  • Try Out This Web App: Enter dotnet run in the command line and either,
  • HTTP Requests
    • GET /api/parks
    • POST /api/parks
    • GET /api/parks/{id}
    • PUT /api/parks/{id}
    • DELETE /api/parks/{id}
  • Endpoints: Use base URL: https://localhost:5000
  • Example Query: https://localhost:5000/api/parks
  • Sample JSON Response:
  {
    "parkId": 5,
    "name": "Molalla River Recreation Area",
    "city": "Molalla",
    "state": "Oregon",
    "managedBy": "Bureau of Land Management",
    "activities": "fishing",
    "amenities": "restrooms",
    "ada": true
  }
  • Path Parameters

Parameter Type Default Required Description
name string none required Return matches by name
city string none required Return matches by city
state string none required Return matches by state
managedBy string none required Return matches by who manages the park
activities string none required Return matches by activities
amenities string none required Return matches by amenities
ada bool none required Return matches if true
  {
    "parkId": 5,
    "name": "Forest Park",
    "city": "Portland",
    "state": "Oregon",
    "managedBy": "Portland Parks and Recreation",
    "activities": "trail running",
    "amenities": "",
    "ada": true
  }

Known Bugs

This is not a real API, which is the greatest shame of all.

License

Copyright (c) Mar 2022 Jessi B

Contact

If you run into any issues or have questions, ideas or concerns or wish to make a contribution to the code see contact information below.


Return to Top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages