Skip to content

ASP.NET 6 project backed by MySQL server utilizing ASP.NET Core Identity for authentication

License

Notifications You must be signed in to change notification settings

mejia-dev/PierresTreats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🥐 Pierre's Treats 🥐

Bakery storefront powered by ASP.NET
View the Site

❔ Description

This project utilizes ASP.NET to allow a shop owner to keep an inventory of "treats" and flavors that they are available in. The project is built in a many-to-many relationship format using EF Core and has full CRUD (Create, Read, Update, Delete) functionality on entities. Additionally, unauthenticated users (customers) can only Read items and can't perform Create, Update, or Delete functions on them.

Features:

  • Allows authenticated users full CRUD of treats and flavors.
  • Allows authenticated users to assign a flavor to any number of treats.
  • Allows authenticated users to assign an treat to any number of flavors.
  • Allows unauthenticated users to view all treats and flavors.

💻 Technologies Used

🔧 Setup / Installation Steps

1 - Setup/Installation Prerequisite Requirements

This section will cover how to install the .NET SDK and MySQL Community Server. If you already have these applications installed and running at at least version 8.0, proceed to the section Project Setup Requirements section below.

Prerequisite A: .NET SDK Installation

Step 1: Download .NET SDK
  • Download the .NET 6 SDK (Software Development Kit). To view all download options for the .NET 6 SDK, visit this page. Or, click on any of the following links for an immediate download from Microsoft:

    For Windows

    For Macs with Apple Chip

    For Macs with Intel Chip

Step 2: Install the SDK
  • Open the file. This will launch an installer which will walk you through installation steps. Use the default settings the installer suggests.
Step 3: Test Installation
  • Confirm the installation is successful. First, restart your command line shell (Terminal or GitBash) if it's already open, and then run the command "dotnet --version" (without quotes). You should see a version number as a response.

Prerequisite B: MySQL Community Server

MacOS Instructions:
MacOS Step 1: Download the MySQL Community Server Installer
MacOS Step 2: Install MySQL Community Server
  • Launch the installer. Accept all prompts 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 a password of your choosing. This password will become necessary later for project setup.
    • Select "Finish".
MacOS Step 3: Configure Environment Variables
  • Open the terminal to set your environment variables using either of the following commands. When finished, close all terminal windows.

    • For bash users:

      echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile
    • For zsh users:

      echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.zshrc
MacOS Step 4: Test Installation (MySQL Community Server)
  • From a new terminal window, attempt to login to mysql to confirm it is configured properly. Substitue "YOUR_PASSWORD_HERE" for the password you set during installation.

    mysql -uroot -pYOUR_PASSWORD_HERE

    There will be an intro message, and the prompt should change to: mysql> . This confirms that mysql is installed and everything is working as expected. If you instead receive a mysql: command not found error, attempt to uninstall any versions of the applications that are previously installed, then follow this installation guide again.

Windows 10/11 Instructions:
Windows Step 1: Download the MySQL Web Installer
Windows Step 2: Install the MySQL Web Programs
  • Follow along with the installer as described below. If a step is not specifically listed, accept the defaults.

    • Select "Yes" if prompted to update.
    • Accept license terms.
    • Choose "Custom" setup type.
    • In the "Select Products and Features" menu, choose the following:
      • Check the box titled "Enable the Select Features page to customize product features".
      • Under MySQL Servers > MySQL Server > MySQL Server 8.0, select "MySQL Server 8.0.19" (or latest available version).
      • Under Applications > MySQL Workbench > MySQL Workbench 8.0, select "MySQL Workbench 8.0.19" (or latest available version).
    • Select "Next", then "Execute". Wait for download and installation. This can take some time.
    • Continue through the following Configuration steps:
      • Set "High Availability" to "Standalone".
      • Set "Type and Networking" to "Defaults are OK".
      • Set "Authentication Method" to "Use Legacy Authentication Method".
      • Set password to a password of your choosing. This password will become necessary later for project setup.
      • Set "Windows Service" to "Defaults are OK". Ensure that the following options are selected:
        • "Configure MySQL Server as a Windows Service".
        • "Start the MySQL Server at System Startup".
        • "Run Windows Service" should be set to "Standard System Account".
    • Complete the installation as prompted.
Windows Step 3: Configure Environment Variables
  • The terminal (CLI, PowerShell, and GitBash) now need to be configured to recognize the mysql command. This can be done through changing the environment variables.

    • Press the Windows key and R key simultaneously to bring up the Run prompt.
    • In the run prompt, type in sysdm.cpl, then press Enter.
    • In the System Properties window that appears, navigate to the "Advanced" tab, then select "Environment Variables...".
      • In the Environment Variables window, under the "System Variables" section, double-click on the "Path" variable to launch it's editing window.
        • In the editing window, select the "New" button in the top right, then enter the installation path of the MySQL Server. For most installations, this should be C:\Program Files\MySQL\MySQL Server 8.0\bin, but may vary depending on the version installed.
        • When finished, select "OK".
      • Select "OK".
    • Select "Apply", then select "OK".
Windows Step 4: Test Installation (MySQL Community Server)
  • Finally, from a new PowerShell window, attempt to login to mysql to confirm it is configured properly. Substitue "YOUR_PASSWORD_HERE" for the password you set during installation.

    mysql -uroot -pYOUR_PASSWORD_HERE.

    There will be an intro message, and the prompt should change to: mysql> . This confirms that mysql is installed and everything is working as expected. If you instead receive a The term 'mysql' is not recognized as the name of a cmdlet, function, script file, or operable program error, double-check that the environment variables were set up correctly. If all else fails, attempt to uninstall any versions of the applications that are previously installed, then follow this installation guide again.

2 - Project Setup Requirements

Step 1: Clone Repo
  • Clone this repository to your desktop by running the following command from your Git Bash console:
     git clone https://github.com/mejia-dev/PierresTreats.git
Step 2: Create appsettings.json
  • This project requires a file titled appsettings.json residing in the project directory (not the root directory).
    • Navigate to the project directory:

      cd PierresTreats/PierresTreats
    • Create the file:

      touch appsettings.json
    • Using a text editor of your choice, modify the file to include the following JSON data:

      {
        "ConnectionStrings": {
          "DefaultConnection": "Server=localhost;Port=3306;database=pierres_treats;uid=YOUR_USERNAME_HERE;pwd=YOUR_PASSWORD_HERE;"
        }
      }

      Please note that the DefaultConnection string is essentially broken up into five distinct lines. Replace data from the template as needed for your environment.

      • Server=localhost;
      • Port=3306;
      • database=pierres_treats;
      • uid=YOUR_USERNAME_HERE;
      • pwd=YOUR_PASSWORD_HERE;

3 - Run the Project

  • Navigate to the project directory, and to the project subfolder:

    cd PierresTreats/PierresTreats
  • Run the following command to install dependencies:

    dotnet restore
  • Run the following command to set up the database schema:

    dotnet ef database update
  • Run the project using:

    dotnet run

⚠️ Known Bugs

If you see an issue, please report it on the Issues page.

  • none

🗣️ User Stories

  • The application should have user authentication. A user should be able to log in and log out. Only logged in users should have create, update, and delete functionality. All users should be able to have read functionality.
  • There should be a many-to-many relationship between Treats and Flavors. A treat can have many flavors (such as sweet, savory, spicy, or creamy) and a flavor can have many treats. For instance, the "sweet" flavor could include chocolate croissants, cheesecake, and so on.
  • A user should be able to navigate to a splash page that lists all treats and flavors. Users should be able to click on an individual treat or flavor to see all the treats/flavors that belong to it. Objectives

⚖️ License

Copyright (C) 2024 Aaron Mejia
Open Source under the GPLv3 License.