Project Initiated: 2021-01-19
Updated: 2021-01-19
This project was created as a crowd source weather saftey application to allow for users to report weather conditions in specific areas.
As a user I, want to get and post reports about user experienced conditions.
As a user I, want to know where this specific report is referenced to.
As a user I, want to limit PUT and DELETE actions to the Report Creator.
As a user I, want reports to be queryable by date, location, inputting user.
- C# and .Net Core installed on your local machine. (Developed on .Net Core v2.2.4)
- Console/Terminal access.
- Code Editor like Visual Studio Code
- MySQL Community Server
- MySQL Workbench
Download .Net Core and follow the installation instructions for your computer's operating system.
Install C# and .Net according to your operating system below:
For Mac
- Download this .NET Core SDK Software Development Kit.
- Open the .pkg file. This will launch an installer which will walk you through installation steps. Use the default settings the installer suggests.
- Confirm the installation is successful by opening your terminal and running the command
dotnet --version
, which should return the correct version number.
For Windows (10+)
- Download either the the 64-bit .NET Core SDK Software Development Kit
- Open the file and follow the steps provided by the installer for your OS.
- Confirm the installation is successful by opening a new Windows PowerShell window and running the command
dotnet --version
You should see a response with the correct version number.
My SQL Installation Below
Windows 10 -
Start by downloading the MySQL Web Installer from the MySQL Downloads page. (Use the No thanks, just start my download link.)
Follow along with the installer:
- Click "Yes" if prompted to update.
- Accept license terms.
- Choose Custom setup type.
- When prompted to Select Products and Features, choose the following:
-
MySQL Server 8.0.19 (This will be under "MySQL Servers > MySQL Server > MySQL Server 8.0")
-
MySQL Workbench 8.0.19 (This will be under "Applications > MySQL Workbench > MySQL Workbench 8.0")
-
Select "Next", then "Execute". Wait for download and installation. (This 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 something you will remember.
-
Defaults are OK under Windows Service. Make sure that checkboxes are checked for the options "Configure MySQL Server as a Windows Service" and "Start the MySQL Server at System Startup". Under Run Windows Service as..., the "Standard System Account" should be selected.
-
Complete Installation process. Next, add the MySQL environment variable to the System PATH. We must include MySQL in the System Environment Path Variable. This is its own multi-step process:
-
Open the Control Panel and visit System and "Security > System". Select "Change Settings" and a pop-up window will display. Select the tab "Advanced" and select the "Environment Variables" button.
-
Within the System Variables navigator window, select PATH..., click Edit..., and then New.
-
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.)
MacOS -
Start by downloading the MySQL Community Server .dmg file from the MySQL Community Server page. Click the download icon. Use the No thanks, just start my download link.
Next, follow along with the Installer until you reach the Configuration page. Once you've reached Configuration, select or set the following options (use default if not specified):
-
Use Legacy Password Encryption.
-
Set password to something you will remember.
-
Click Finish.
-
Open the terminal and enter the command echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile. This will save this path in .bash_profile, which is where our terminal is configured.
-
Type in source ~/.bash_profile (or restart the terminal) in order to actually verify that MySQL was installed.
Next, verify MySQL installation by opening terminal and entering the command mysql -uroot -pepicodus. You'll know it's working and connected if you gain access and see the MySQL command line. If it's not working, you'll likely get a -bash: mysql: command not found error.
You can exit the mysql program by entering exit.
Next, download the MySQL Workbench .dmg file from the MySQL Workbench page. (Use the No thanks, just start my download link.)
Install MySQL Workbench to Applications folder.
Then open MySQL Workbench and select the Local instance 3306 server. You will need to enter the password you set. (We used epicodus.) If it connects, you're all set.
- Navigate to the Mt.Safe API Repository.
- Click 'Clone or download' to reveal the HTTPS url ending with .git and the 'Download ZIP' option.
- Open up your system Terminal or GitBash, navigate to your desktop with the command:
cd Desktop
, or whichever location suits you best. - Clone the repository to your desktop:
$ git clone https://github.com/MaxBrockbank/MtSafe.Solution.git
- Run the command
cd MtSafe.Solution
to enter into the project directory. - View or Edit:
- Code Editor - Run the command
atom .
orcode .
to open the project in Atom or VisualStudio Code respectively for review and editing. - Text Editor - Open by double clicking on any of the files to open in a text editor.
- Code Editor - Run the command
- Navigate to the Mt.Safe API Repository.
- Click 'Clone or download' to reveal the HTTPS url ending with .git and the 'Download ZIP' option.
- Click 'Download ZIP' and unextract.
- Open by double clicking on any of the files to open in a text editor.
- Create a new file in the CoffeeTrackerAPI.Solution/CoffeeTrackerAPI directory named
appsettings.json
- Add in the following code snippet to the new appsettings.json file:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Port=3306;database=mt_safe;uid=root;pwd=YourPassword;"
}
}
- Change the server, port, and user id as necessary. Replace 'YourPassword' with relevant MySQL password (set at installation of MySQL).
- Navigate to MtSafe.Solution/MtSafe directory using the MacOS Terminal or Windows Powershell (e.g.
cd Desktop/MtSafeAPI.Solution/MtSafe
). - Run the command
dotnet ef database update
to generate the database through Entity Framework Core. - (Optional) To update the database with any changes to the code, run the command
dotnet ef migrations add <MigrationsName>
which will use Entity Framework Core's code-first principle to generate a database update. After, run the previous commanddotnet ef database update
to update the database.
- Navigate to MtSafe.Solution/MtSafe directory using the MacOS Terminal or Windows Powershell (e.g.
cd Desktop/MtSafe.Solution/MtSafe
). - Run the command
dotnet run
to have access to the API in Postman or browser. - SIDENOTE: If changes are made to the Controller file you will need to run the
dotnet build
command before you can rundotnet run
to see your changes active.
Explore the API endpoints in Postman or a browser. You will not be able to utilize authentication in a browser.
To explore the CoffeeTracker API with NSwag, launch the project using dotnet run
with the Terminal or Powershell, and input the following URL into your browser: http://localhost:5000/swagger
http://localhost:5000/api/2.0/reports?username=Albert
..........................................................................................
Base URL: https://localhost:5000
Access user created snow reports.
GET /api/reports
POST /api/reports
PUT /api/reports/{id}
DELETE /api/reports/{id}
GET /api/2.0/reports/{condition, location, username}
Parameter | Type | Default | Required | Description |
---|---|---|---|---|
condition | string | none | false | Return matches by name. |
location | string | none | false | Return any bean from a specific country or region of origin. |
username | string | none | false | Return bean matches with a specific flavor profile. |
..........................................................................................
No new features are planned at this time.
There are no known bugs
- C# 7.3
- .NET Core 2.2
- Entity
- Git
- MySQL
- CSS
- HMTL
- Bootstrap
- Razor
- dotnet script, REPL
- Mvc.Versioning 4.1.0
- Swachbuckle 5.5.0
Authored by: Ryland Adams Authored by: Kevin Kirkley Authored by: Max Brockbank
Ryland Adams - [email protected] Kevin Kirkley [email protected] Max Brockbank - [email protected]
GPLv3
Copyright © 2020 Ryland Adams, Kevin Kirkley, Max Brockbank