Skip to content

This is the Web Service (Server) portion of our Internship project. Built with .NET WebApi SDK and Entity Framework.

License

Notifications You must be signed in to change notification settings

YGOhappy123/NHT_Marine_BE

Repository files navigation

NHT Marine - Web Service

This is the Web Service (Server) portion of our Internship project. Built with .NET WebApi SDK and Entity Framework.

Table of Contents

Technologies Used

Required Dependencies

  • .NET 8.0.403 SDK
  • Entity Framework Core
  • Microsoft SQL Server 2022 - Express edition
  • Microsoft SQL Server Management Studio - SSMS

Make sure to have these installed before proceeding with the project setup.

Note: If you encounter any issues installing the .NET runtime, consider installing it through Visual Studio. Details are provided below.

Installation

Install dotnet runtime through Visual Studio

Follow these steps to download Visual Studio 2022 and dotnet runtime.

  1. Download Visual Studio 2022:

  2. Launch the Visual Studio Installer:

    • After downloading the installer, open it to start setting up Visual Studio.
    • You'll be prompted to select workloads to install.
  3. Select the .NET Workloads and start the installation:

    • In the Workloads tab, find the section labeled ASP.NET and web development.
    • Check the box for ASP.NET and web development to install all necessary tools.
    • Click Install to download and install the selected features.
  4. Verify .NET Runtime:

    • After the installation, you can verify the installed .NET runtime by opening a terminal and typing the following command:

      dotnet --version
    • It should return the version of the .NET SDK installed by Visual Studio.

Cloning the project and install dependencies

Follow these steps to set up and run the application locally.

  1. Clone the repository:

    git clone https://github.com/YGOhappy123/NHT_Marine_BE.git
  2. Navigate to the project directory:

    cd NHT_Marine_BE
  3. Install dependencies:

    dotnet restore

Before You Run

Before running the project, make sure to set up the database and environment variables:

  1. Create a appsettings.Development.json file:

    In the root directory of your project (at the same level as Program.cs), create a appsettings.Development.json file.

  2. Populate the environment variables:

    Copy the structure from appsettings.Example.json file into appsettings.Development.json and replace the placeholder values with your actual configuration.

    Notes:

    • You must replace <your_server_name> with the actual value of your local Microsoft SQL Server instance.

    • Ensure that NHT_Marine (the database name) is correct, as the application uses migrations that depend on this database.

  3. For collaborators:

    If you are a collaborator on this project, please contact the project owner to obtain the values for the environment variables.

  4. Apply the migrations to create the necessary database tables. Use the following command in the terminal:

    dotnet ef database update

    This command will apply the existing migrations to the specified database, ensuring that the required tables are created.

    Note: If you encounter any errors like dotnet-ef: command not found, install the dotnet-ef tool globally on your machine using the following command an retry:

    dotnet tool install --global dotnet-ef --version 8.0.10
  5. Verify the created database:

    If you don't see a database name NHT_Marine in your SQL Server Management Studio after refreshing, try disconnecting and reconnecting your SQL Server.

Development

To start the development server, use:

dotnet watch run

This will start the Dotnet development server

You can access the app by visiting http://localhost:5000/api/v1 in your browser.

You can also replace localhost with your device's IPv4 Address, which can be found by entering the following command in the terminal and look for Wireless LAN adapter Wi-Fi > IPv4 Address:

ipconfig

Connect Other Devices To This Server

Requirement: All devices must be connected to the same network.

Follow these steps to ensure that your firewall allows incoming connections on port 5000.

  1. Open Windows Defender Firewall.
  2. Click on Advanced settings.
  3. Select Inbound Rules and then New Rule.
  4. Choose Port, click Next.
  5. Select TCP and enter 5000 in the specific local ports box.
  6. Allow the connection and complete the wizard.

Now you can access the app using other devices by visiting http://<IPv4 Adddess>:5000/api/v1

Features

  • RESTful API 🛠 Exposes endpoints following REST principles for ease of use and scalability.
  • Database Integration 💾 Uses Microsoft SQL Server with Entity Framework Core for data persistence.
  • Swagger Documentation 📜 Automatically generated API documentation with Swagger/OpenAPI.
  • Authentication and Authorization 🔑 Secure your API with JWT-based authentication.
  • Cross-Platform 🌐 Runs on any operating system that supports .NET Core.
  • Migrations 🔄 Easily handle database schema changes using Entity Framework Core migrations.

Suggested VS Code Extensions

Extension Publisher Required? Supported features
C# Dev Kit Microsoft Yes Install necessary tools for developing C# and .NET app
.NET Extension Pack Microsoft Yes Install necessary tools for developing C# and .NET app
CSharpier - Code formatter csharpier Yes Code formatting
NuGet Gallery pcislo Yes Streamlining the process of managing NuGet packages
IntelliCode for C# Dev Kit Microsoft No AI-assisted development for C# Dev Kit
C# Extensions JosKreativ No Add C# related stuffs to VS Code context menu
Code Spell Checker Street Side Software No Spelling checker for source code
Multiple cursor case preserve Cardinal90 No Preserves case when editing with multiple cursors

Contributors

Thanks to the following people for contributing to this project ✨:

YGOhappy123
YGOhappy123
DinhToanIT2003
DinhToanIT2003
Nguyen1609
Nguyen1609

About

This is the Web Service (Server) portion of our Internship project. Built with .NET WebApi SDK and Entity Framework.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •