Description • Requirements • Installation • Contributors • License
This program is an API created to allow access to a database of local businesses and their relevant information. It was built with C#/.NET, using Entity Framework to build and integrate with a MySql database. The program has full Index and CRUD functionality, programs accessing the API being capable of accessing an Index of all restaurants and shops in the database as well as of adding a new business to the database, viewing a single business, editing the information of any business in the database, and deleting any business in the database. Additionally, the program integrates pagination capability, allowing programs that access the API to obtain and display paged database information.
- Git v2.62.2 or Later
- MySql Workbench
- Postman v7.30.1 or Later
- Visual Studio Code
- .NET Core v2.2 or Later
- Make sure you have installed all required software.
- Open your computer's terminal and navigate to the directory in which you would like the program to be stored.
- Enter the command
git clone https://github.com/taylorsomers/LocalBusinessAPI.Solution
in the terminal. - Open the file
LocalBusinessAPI.Solution/LocalBusiness/appsettings.json
. - In
appsettings.json
, update theusername
andpassword
values with your local MySql username and password. - Using the terminal, navigate to the
LocalBusinessAPI.Solution/LocalBusiness
directory. - Enter the command
dotnet restore
in the terminal. - Enter the command
dotnet build
in the terminal. - Enter the command
dotnet ef database update
in the terminal. - Enter the command
dotnet run
in the terminal. The program should begin running and be accessible by any other program capable of making API requests.
CREATE DATABASE IF NOT EXISTS taylor_somers
;
USE taylor_somers
;
DROP TABLE IF EXISTS __efmigrationshistory
;
CREATE TABLE __efmigrationshistory
(
MigrationId
varchar(95) NOT NULL,
ProductVersion
varchar(32) NOT NULL,
PRIMARY KEY (MigrationId
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
DROP TABLE IF EXISTS restaurants
;
CREATE TABLE restaurants
(
RestaurantId
int NOT NULL AUTO_INCREMENT,
RestaurantName
longtext,
RestaurantAddress
longtext,
RestaurantType
longtext,
RestaurantYelpRating
longtext,
PRIMARY KEY (RestaurantId
)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
DROP TABLE IF EXISTS shops
;
CREATE TABLE shops
(
ShopId
int NOT NULL AUTO_INCREMENT,
ShopName
longtext,
ShopAddress
longtext,
ShopType
longtext,
ShopYelpRating
longtext,
PRIMARY KEY (ShopId
)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Functionality | Request Type | HTTP Route |
---|---|---|
Index | GET |
/api/restaurants |
Index | GET |
/api/shops |
Create | POST |
/api/restaurants |
Create | POST |
/api/shops |
Read | GET |
/api/restaurants/{id} |
Read | GET |
/api/shops/{id} |
Update | PUT |
/api/restaurants/{id} |
Update | PUT |
/api/shops/{id} |
Delete | DELETE |
api/restaurants/{id} |
Delete | DELETE |
api/shops/{id} |
Parameter | Type | Default | Required | Description |
---|---|---|---|---|
restaurantname |
string | none | false | Returns restaurants by queried name. |
restaurantaddress |
string | none | false | Returns restaurants by queried address. |
restauranttype |
string | none | false | Returns restaurants by queried type. |
restaurantyelprating |
string | none | false | Returns restaurants by queried Yelp rating. |
shopname |
string | none | false | Returns shops by queried name. |
shopaddress |
string | none | false | Returns shops by queried address. |
shoptype |
string | none | false | Returns shops by queried type. |
shopyelprating |
string | none | false | Returns shops by queried Yelp rating. |
Sample Query | Sample JSON Response |
---|---|
localhost:5000/api/restaurants/?restauranttype=barbecue |
{"restaurantId": 6, "restaurantName": "Tom & Flip's BBQ", "restaurantAddress": "8465 Adams Dr, Greer, SC 29650", "restaurantType": "Barbecue", "restaurantYelpRating": "4 Stars"}, {"restaurantId": 7, "restaurantName": "City of Pigs", "restaurantAddress": "8465 Adams Dr, Greer, SC 29650", "restaurantType": "Barbecue", "restaurantYelpRating": "3 Stars"} |
- The Local Business API returns a default count of 3 restaurants per page and 5 shops per page.
- To modify the default result count per page, use
limit
andstart
query parameters to change the number of results displayed per page.
Location : Message | Situation | Resolved (Y/N) | Bug Resolution Strategy |
---|---|---|---|
Terminal : Unable to create an object of type 'LocalBusinessContext'. |
Error thrown when attempting Initial migration. | Y | Add DesignTimeDbContextFactory.cs file to LocalBusiness/Models directory. |
- You are welcome to contact the author via GitHub with any concerns, feedback, possible contributions, questions, or suggestions.
- Taylor Somers
- README Photo Credit: Olivia Hutcherson
- This program is free to use under the GNU Affero General Public License AGPLv3. © 2020 Taylor Somers. All rights reserved.