GithubHelp home page GithubHelp logo

jhenager / portlandbusinessapi.solution Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 17 KB

API made for Epicodus to demonstrate an understanding of API creation in ASP.net core MVC using SQL with Entity framework and Swagger Documentation

C# 100.00%
postman portland database api mysql entityframeworkcore epicodus entity swagger-documentation nswag

portlandbusinessapi.solution's Introduction

Portland Businesses API

API made for Epicodus to demonstrate understanding of API creation in ASP.net core mvc using SQL with Entity framework and Swagger Documentation

ABOUT

This API is designed to collect and display all of Portland, Oregon's finest restaurants and shops. It can be utilized with a front-end application such as .NET MVC, or queried independently.

REQUIREMENTS

SETUP

copy this url to clone this project to your local system:

https://github.com/jhenager/PortlandBusiness.Solution.git

Once copied, select "Clone Repository" from within VSCode & paste the copied link.


With the project open to the root directory, navigate to the production directory with the following command in your terminal.

cd PortlandBusiness

Then, install the necessary packages with the following command

dotnet restore 

Finally, you can start the program with this command.

dotnet run 

Setting up the database


Next we will need to setup our MySql database for the application to work.
First, you will need to update the username and password in the appsettings.json file to match your local username and password. Replace the word "root" with your username, and the word "epicodus" with your password. Be sure to leave the "u" and "p" in there as they stand for username and password respectively.
Because the project already has migrations and seeded data, all you will need to do is update the database.
dotnet ef database update


PROTECTING YOUR DATA

Step 1: From within VSCode in the root project directory, we will create a .gitignore file

For l-top

touch .gitignore 

For l-top

ni .gitignore 

Step 2: Add the following to your .gitignore file (this protects your sensitive data).

DO NOT PROCEED UNTIL YOU DO!

node_modules/
.DS_store
dist/
appsettings.json
bin/
obj/

Step 3: To commit your .gitignore file enter the following commands

git add .gitignore
git commit -m "protect data"

Using Postman to query the database

First we are going to start a localhost server in the PortlandBusiness project folder. In the command line enter:

dotnet watch run

Once the project has built, Open Postman and Click on the plus sign in the middle of the page (or the plus sign that says "New" in the corner).

GET Request

To get all of either the Restaurants or Shops in this API and view them enter "http://localhost5000/api/restaurants" or "http://localhost5000/api/shops" respectively into the search bar with "GET" selected on the dropdown. Results will look like:

[
  {
    "restaurantId": 1,
    "name": "Ground Kontrol",
    "type": "Bar",
    "description": "Downtown Arcade Bar"
  },
  {
    "restaurantId": 2,
    "name": "Laurelhurst Market",
    "type": "Steakhouse",
    "description": "Restaurant and Deli providing fine meats"
  },
  {
    "restaurantId": 3,
    "name": "Soro Soro",
    "type": "Dessert",
    "description": "Korean desserts and coffee drinks"
  },

GET ID Request

To get one particular Restaurant or Shop in this API and view them enter "http://localhost5000/api/restaurants/1" or "http://localhost5000/api/shops/1" respectively into the search bar with "GET" selected on the dropdown. The "1" in the url can be replaced with any other number to retrieve the object with that ID. Click Send, results will look like:

  {
    "restaurantId": 1,
    "name": "Ground Kontrol",
    "type": "Bar",
    "description": "Downtown Arcade Bar"
  },

Post Request

To add an entry to either the Restaurants or Shops in this API enter "http://localhost5000/api/restaurants" or "http://localhost5000/api/shops" respectively into the search bar with "Post" selected on the dropdown. Before clicking send, click on the tab marked body, the click on the radio button that saws raw. Paste the following into the body, replace the values with the values you wish and click send.

{
  "restaurantId": 0,
  "name": "string",
  "type": "string",
  "description": "string"
}

Put Request

To edit an entry in either Restaurants or Shops in this API enter "http://localhost5000/api/restaurants/1" or "http://localhost5000/api/shops/1" respectively into the search bar with "Put" selected on the dropdown. Replace the "1" with the id of the entry you would like to edit. Before clicking send, click on the tab marked body, the click on the radio button that saws raw. Paste the following into the body, replace the values with the values you wish and click send.

{
  "restaurantId": 0,
  "name": "string",
  "type": "string",
  "description": "string"
}

Delete Request

To add an entry to either the Restaurants or Shops in this API enter "http://localhost5000/api/restaurants/1" or "http://localhost5000/api/shops/1" respectively into the search bar with "Delete" selected on the dropdown. Replace the "1" with the id of the entry you would like to delete. Click send to delete the entry.

Viewing Swagger Documentation

To view all of the API's endpoint documentation with swagger, first make sure a live server is running. If it isn't, navigate into the PortlandBusiness project folder in the command line and enter:

dotnet watch run

Then in your web browser, navigate to "http://localhost5000/swagger"
Click on each tab and experiment with the "try it out" button to see how the different endpoints function.

QUESTIONS AND CONCERNS

Questions, comments and concerns can be directed to James Henager ([email protected])


Technologies Used

Written in: Visual Studio Code

Database Mgmt: MySql Workbench


portlandbusinessapi.solution's People

Contributors

jhenager avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.