Best Restaurants Tracker

MySQL & Entity Framework Core project for Epicodus, Mar. 18 2020

By Michelle Morin, Alex Skreen, Todd Walraven

Description

This application allows users to keep track of restaurants, assign restaurants to different cuisines, and assign reviews to restaurants.

Specifications:

Specification Example Input Example Output
Application creates instance of an Cuisine object Cuisine newCuisine = new Cuisine(type) new Cuisine object created
Application creates instance of an Restaurant object Restaurant newRestaurant = new Restaurant(name, priceRange, cuisineId) new Restaurant object created
Application creates instance of an Review object Review newReview = new Review(title, description, restaurantId) new Review object created
Application saves all new cuisines in database table named cuisines new cuisine object instantiated new cuisine object saved as row in database table
If user visits '/' root route, applications displays splash page with link to '/cuisines' and '/restaurants' user visits '/' route displays homepage
If user visits '/cuisines' route, applications displays all cuisines in database, each clickable to view all restaurants in the cuisine type user visits '/cuisines' route displays list of cuisine types
If user clicks "add new cuisine" link, application redirects to new cuisine form user clicks "add new cuisine" link application redirects to new cuisine form
If user visits '/cuisines/new', application shows new cuisine form user visits '/cuisines/new' application displays form for adding new cuisine
If user visits submits new cuisine form, application adds new cuisine to database and redirects to '/cuisines' user submits form application adds new cuisine to database and redirects to page showing all cuisines in database
If user visits '/cuisines/{id}', application displays all restaurants for that cuisine user clicks on specific cuisine in list application redirects to display all restaurants for that cuisine
If user clicks on restaurant name, application redirects to page displaying details for that restaurant user clicks restaurant name webpage redirects to page displaying name, price range, and reviews for restaurant
Application allows users to add review for a restaurant user clicks "add review" webpage redirects to form for adding review

Setup/Installation Requirements

Install .NET Core

on macOS:

  • Click here to download a .NET Core SDK from Microsoft Corp.
  • Open the file (this will launch an installer which will walk you through installation steps. Use the default settings the installer suggests.)

on Windows:

  • Click here to download the 64-bit .NET Core SDK from Microsoft Corp.
  • Open the .exe file and follow the steps provided by the installer for your OS.

Install dotnet script

Enter the command dotnet tool install -g dotnet-script in Terminal (macOS) or PowerShell (Windows).

Install MySQL and MySQL Workbench

on macOS:

Download the MySQL Community Server DMG File here. Follow along with the installer until you reach the configuration page. Once you've reached Configuration, set the following options (or user default if not specified):

  • use legacy password encryption
  • set password (and change the password field in appsettings.json file of this repository to match your password)
  • click finish
  • open Terminal and enter the command echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile if using Git Bash.
  • Verify MySQL installation by opening Terminal and entering the command mysql -uroot -p{your password here, omitted brackets}. If you gain access to the MySQL command line, installation is complete. An error (e.g., -bash: mysql: command not found) indicates something went wrong.

Download MySQL Workbench DMG file here. Install MySQL Workbench to Applications folder. Open MySQL Workbench and select Local instance 3306 server, then enter the password you set. If it connects, you're all set.

on Windows:

Download the MySQL Web Installer here and follow along with the installer. Click "Yes" if prompted to update, and accept license terms.

  • Choose Custom setup type
  • When prompted to Select Products and Features, choose the following: MySQL Server (Will be under MySQL Servers) and MySQL Workbench (Will be under Applications)
  • Select Next, then Execute. Wait for download and installation (can take a few minutes)
  • Advance through Configuration as follows:
    • High Availability set to Standalone.
    • Defaults are OK under Type and Networking.
    • Authentication Method set to Use Legacy Authentication Method.
    • Set password to epicodus. You can use your own if you want but epicodus will be assumed in the lessons.
    • Unselect Configure MySQL Server as a Windows Service.
  • Complete installation process

Add the MySQL environment variable to the System PATH. Instructions for Windows 10:

  • Open the Control Panel and visit System > Advanced System Settings > Environment Variables...
  • Select PATH..., click Edit..., then Add.
  • Add the exact location of your MySQL installation and click OK. (This location is likely C:\Program Files\MySQL\MySQL Server 8.0\bin, but may differ depending on your specific installation.)
  • Verify installation by opening Windows PowerShell and entering the command mysql -uroot -p{your password here, omitted brackets}. It's working correctly if you gain access to the MySQL command line. Exit MySQL by entering the command exit.
  • Open MySQL Workbench and select Local instance 3306 server (may be named differently). Enter the password you set, and if it connects, you're all set.

Clone this repository

Enter the following commands in Terminal (macOS) or PowerShell (Windows):

  • cd desktop
  • git clone followed by the URL to this repository
  • cd ToDoList.Solution

Confirm that you have navigated to the BestRestaurants.Solution directory (e.g., by entering the command pwd in Terminal).

Recreate the best_restaurants database using the following MySQL commands (in Terminal on macOS or PowerShell on Windows):

  • CREATE DATABASE best_restaurants;
  • USE best_restaurants;
  • CREATE TABLE cuisines ( CuisineId int(11) NOT NULL AUTO_INCREMENT, Type varchar(255) DEFAULT NULL, PRIMARY KEY (CuisineId) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
  • CREATE TABLE restaurants ( RestaurantId int(11) NOT NULL AUTO_INCREMENT, Name varchar(255) DEFAULT NULL, PriceRange varchar(255) DEFAULT NULL, CuisineId int(11) DEFAULT '0', PRIMARY KEY (RestaurantId) ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
  • CREATE TABLE reviews ( ReviewId int(11) NOT NULL AUTO_INCREMENT, Title varchar(255) DEFAULT NULL, Description varchar(255) DEFAULT NULL, RestaurantId int(11) DEFAULT '0', PRIMARY KEY (ReviewId) ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

Run this application by entering the following command in Terminal (macOS) or PowerShell (Windows):

  • cd BestRestaurants
  • dotnet restore
  • dotnet build
  • dotnet run or dotnet watch run

To view/edit the source code of this application, open the contents of this directory in a text editor or IDE of your choice (e.g., to open all contents of the directory in Visual Studio Code on macOS, enter the command code . in Terminal).

Technologies Used

  • Git
  • HTML
  • CSS
  • C#
  • .NET Core 2.2
  • ASP.NET Core MVC (version 2.2)
  • Razor
  • dotnet script
  • MySQL
  • MySQL Workbench
  • Entity Framework Core 2.2

License

This webpage is licensed under the MIT license.

Copyright (c) 2020 Michelle Morin, Todd Walraven, Alex Skreen