This project is a 3-tier web application built with .NET and MongoDB. The application consists of a presentation layer, a business logic layer, and a data access layer. MongoDB is used as the database to store and manage application data.
Before setting up the project, ensure you have the following installed on your machine:
- Ubuntu (or another compatible Linux distribution)
- .NET SDK 8.0
- MongoDB 7.0
To install the .NET SDK and Runtime, execute the following commands in your terminal:
-
Install .NET SDK 8.0:
sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-8.0
-
Install .NET Runtime 8.0:
sudo apt-get update && \ sudo apt-get install -y aspnetcore-runtime-8.0
To install MongoDB, execute the following commands in your terminal:
-
Add MongoDB's GPG key and repository:
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \ sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \ --dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
-
Install MongoDB:
sudo apt update sudo apt install -y mongodb-org
-
Enable and Start MongoDB service:
sudo systemctl enable mongod sudo systemctl start mongod
-
Install MongoDB Shell:
Follow the installation guide at MongoDB Shell Installation.
-
Access MongoDB Terminal:
To interact with your MongoDB instance, open the MongoDB shell using:
mongosh
-
Manipulate Databases and Collections:
-
Show databases:
show dbs;
-
Use a specific database:
use db_name;
-
Show collections in the database:
show collections;
-
Query the
Products
collection:db.Products.find().pretty();
-
To run the .NET application:
-
Navigate to the root directory where
Program.cs
is located. -
Build the application:
dotnet build
-
Run the application:
dotnet run
The application will start, and you can access it in your web browser.
To manipulate your MongoDB database using MongoDB Shell:
-
Start the shell:
mongosh
-
Example commands:
-
List all databases:
show dbs;
-
Switch to a specific database:
use db_name;
-
Show collections in the current database:
show collections;
-
Find all documents in a collection:
db.Products.find().pretty();
-
This project is licensed under the MIT License - see the LICENSE file for details.