Project Initiated: 01-15-2021
Updated: 01-15-2021
This project was designed to display my comprehension of many to many relationships and Authentication with Identity using C# and Mvc framework. Users have the ability to log into the web application and create a list of flavors that contain many treats and treats that have many flavors. User has the ability to update these items in a local database.
ID | User Story | Accepted |
---|---|---|
US01 | "As a user, I want to add a treat for a flavor, so I can create details for each item." | True |
US02 | "As a user, I want to add a flavor for a treat, so I can create details for each item." | True |
US03 | "As a user, I want to be able to update and delete treats and flavors, so I can have flexibility with how I categorize items." | True |
US04 | "As a user, I want to edit my treats and flavors, so I can make improvements or corrections to my items." | True |
US05 | "As a user, I want to be able to delete treats and flavors I don't like or use, so I don't have to see them as choices." | True |
US06 | "As a user, I want to rate my treats and flavors, so I know which ones are the best." | True |
US07 | "As a user, I want to list my treats and flavors by highest rated so I can see which ones I like the best." | True |
US08 | "As a user, I want to see all treats that use a certain ingredient, so I can more easily find treats with a certain ingredient in mind." | True |
US09 | "As a user, I want to see all flavors that use a certain description, so I can more easily find flavors with a certain description in mind." | True |
US10 | "As a user, I want to be able to login, so I can create treats and flavors for the bakery." | True |
- 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.
Option 1 (download zip file)
- Copy and paste the following GitHub project link into your web browser's url bar and hit enter/return. https://github.com/HarrisonStrand/PierresTreats.Solution.git
- Download a .zip copy the repository by clicking on the large green "Code" button near the upper right corner of the screen.
- Right click the .zip file and extract(unzip) it's contents.
- Open your computer's terminal/console, and navigate to folder called "PierresTreats.Solution".
Option 2 (via git console/terminal)
-
Open your Git enabled terminal/console and navigate to a directory that you wish to download this project to.
-
Type the following line of code into your terminal/console to automatically download the project to your current direcory and hit return/enter
git clone https://github.com/HarrisonStrand/PierresTreats.Solution.git
-
Once the project has finished downloading, use the terminal/console to navigate to the "PierresTreats.Solution" folder of the project.
Setup Database Connection
Create a new file in the root directory of the PierresTreats.Solution/PierresTreats directory named "appsettings.json". Copy and past the following code inside of the file.
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Port=3306;database=harrison_strand;uid=YourId;pwd=YourPassword;"
}
}
Replace "YourId" and "YourPassword" in the code above with the user id and user password you use for logging into MySQL Workbench. Save the "appsettings.json" file.
Type the following code and hit enter/return to install the necessary dependencies.
dotnet restore
Once the dependencies have installed, type the following commands into your console, hitting enter/return after each.
dotnet ef database update
You can now type the follow code to launch the program...
dotnet run
The program should launch using your default web browser at URL: localhost:5000.
-- MySQL dump 10.13 Distrib 8.0.15, for macos10.14 (x86_64)
--
-- Host: localhost Database: harrison_strand
-- ------------------------------------------------------
-- Server version 8.0.15
--
-- Table structure for table `__EFMigrationsHistory`
--
DROP TABLE IF EXISTS `__EFMigrationsHistory`;
SET character_set_client = utf8mb4 ;
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;
--
-- Table structure for table `AspNetRoleClaims`
--
DROP TABLE IF EXISTS `AspNetRoleClaims`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `AspNetRoleClaims` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`RoleId` varchar(255) NOT NULL,
`ClaimType` longtext,
`ClaimValue` longtext,
PRIMARY KEY (`Id`),
KEY `IX_AspNetRoleClaims_RoleId` (`RoleId`),
CONSTRAINT `FK_AspNetRoleClaims_AspNetRoles_RoleId` FOREIGN KEY (`RoleId`) REFERENCES `aspnetroles` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Table structure for table `AspNetRoles`
--
DROP TABLE IF EXISTS `AspNetRoles`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `AspNetRoles` (
`Id` varchar(255) NOT NULL,
`Name` varchar(256) DEFAULT NULL,
`NormalizedName` varchar(256) DEFAULT NULL,
`ConcurrencyStamp` longtext,
PRIMARY KEY (`Id`),
UNIQUE KEY `RoleNameIndex` (`NormalizedName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Table structure for table `AspNetUserClaims`
--
DROP TABLE IF EXISTS `AspNetUserClaims`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `AspNetUserClaims` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`UserId` varchar(255) NOT NULL,
`ClaimType` longtext,
`ClaimValue` longtext,
PRIMARY KEY (`Id`),
KEY `IX_AspNetUserClaims_UserId` (`UserId`),
CONSTRAINT `FK_AspNetUserClaims_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `aspnetusers` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Table structure for table `AspNetUserLogins`
--
DROP TABLE IF EXISTS `AspNetUserLogins`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `AspNetUserLogins` (
`LoginProvider` varchar(255) NOT NULL,
`ProviderKey` varchar(255) NOT NULL,
`ProviderDisplayName` longtext,
`UserId` varchar(255) NOT NULL,
PRIMARY KEY (`LoginProvider`,`ProviderKey`),
KEY `IX_AspNetUserLogins_UserId` (`UserId`),
CONSTRAINT `FK_AspNetUserLogins_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `aspnetusers` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Table structure for table `AspNetUserRoles`
--
DROP TABLE IF EXISTS `AspNetUserRoles`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `AspNetUserRoles` (
`UserId` varchar(255) NOT NULL,
`RoleId` varchar(255) NOT NULL,
PRIMARY KEY (`UserId`,`RoleId`),
KEY `IX_AspNetUserRoles_RoleId` (`RoleId`),
CONSTRAINT `FK_AspNetUserRoles_AspNetRoles_RoleId` FOREIGN KEY (`RoleId`) REFERENCES `aspnetroles` (`Id`) ON DELETE CASCADE,
CONSTRAINT `FK_AspNetUserRoles_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `aspnetusers` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Table structure for table `AspNetUsers`
--
DROP TABLE IF EXISTS `AspNetUsers`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `AspNetUsers` (
`Id` varchar(255) NOT NULL,
`UserName` varchar(256) DEFAULT NULL,
`NormalizedUserName` varchar(256) DEFAULT NULL,
`Email` varchar(256) DEFAULT NULL,
`NormalizedEmail` varchar(256) DEFAULT NULL,
`EmailConfirmed` bit(1) NOT NULL,
`PasswordHash` longtext,
`SecurityStamp` longtext,
`ConcurrencyStamp` longtext,
`PhoneNumber` longtext,
`PhoneNumberConfirmed` bit(1) NOT NULL,
`TwoFactorEnabled` bit(1) NOT NULL,
`LockoutEnd` datetime(6) DEFAULT NULL,
`LockoutEnabled` bit(1) NOT NULL,
`AccessFailedCount` int(11) NOT NULL,
PRIMARY KEY (`Id`),
UNIQUE KEY `UserNameIndex` (`NormalizedUserName`),
KEY `EmailIndex` (`NormalizedEmail`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `AspNetUserTokens`
--
DROP TABLE IF EXISTS `AspNetUserTokens`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `AspNetUserTokens` (
`UserId` varchar(255) NOT NULL,
`LoginProvider` varchar(255) NOT NULL,
`Name` varchar(255) NOT NULL,
`Value` longtext,
PRIMARY KEY (`UserId`,`LoginProvider`,`Name`),
CONSTRAINT `FK_AspNetUserTokens_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `aspnetusers` (`Id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Table structure for table `Flavors`
--
DROP TABLE IF EXISTS `Flavors`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `Flavors` (
`FlavorId` int(11) NOT NULL AUTO_INCREMENT,
`FlavorName` longtext,
`StarRating` longtext,
`Description` longtext,
`UserId` varchar(255) DEFAULT NULL,
PRIMARY KEY (`FlavorId`),
KEY `IX_Flavors_UserId` (`UserId`),
CONSTRAINT `FK_Flavors_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `aspnetusers` (`Id`) ON DELETE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Table structure for table `FlavorTreat`
--
DROP TABLE IF EXISTS `FlavorTreat`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `FlavorTreat` (
`FlavorTreatId` int(11) NOT NULL AUTO_INCREMENT,
`FlavorId` int(11) NOT NULL,
`TreatId` int(11) NOT NULL,
PRIMARY KEY (`FlavorTreatId`),
KEY `IX_FlavorTreat_FlavorId` (`FlavorId`),
KEY `IX_FlavorTreat_TreatId` (`TreatId`),
CONSTRAINT `FK_FlavorTreat_Flavors_FlavorId` FOREIGN KEY (`FlavorId`) REFERENCES `flavors` (`FlavorId`) ON DELETE CASCADE,
CONSTRAINT `FK_FlavorTreat_Treats_TreatId` FOREIGN KEY (`TreatId`) REFERENCES `treats` (`TreatId`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Table structure for table `Treats`
--
DROP TABLE IF EXISTS `Treats`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `Treats` (
`TreatId` int(11) NOT NULL AUTO_INCREMENT,
`TreatName` longtext,
`Ingredients` longtext,
`StarRating` longtext,
`UserId` varchar(255) DEFAULT NULL,
PRIMARY KEY (`TreatId`),
KEY `IX_Treats_UserId` (`UserId`),
CONSTRAINT `FK_Treats_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `aspnetusers` (`Id`) ON DELETE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
No new features are planned at this time.
There are no known bugs
- C# 7.3
- .NET Core 2.2
- Entity
- Identity
- Git
- MySQL
- CSS
- HMTL
- Bootstrap
- Razor
- dotnet script, REPL
Author | |
---|---|
Harrison Strand | harrisonstrand@gmail.com |
MIT License
Copyright (c) 2021 Harrison Strand
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.