This project is a SaaS-based API built using .NET Core, implementing multi-tenancy with row-level security. It provides Tenant Management and User CRUD operations, ensuring secure data access per tenant.
- Multi-Tenant Architecture
- Row-Level Security using TenantId
- CRUD operations for Users
- Middleware for Exception Handling & Request Logging
- Uses Stored Procedures for Database Access
WebApi.Solution
│-- WebApi # API Project
│-- WebApi.Common # Common Utilities
│-- WebApi.Entity # Entity Models
│-- WebApi.Repository # Data Access Layer
│-- WebApi.Service # Business Logic Layer
│-- WebApi.Middleware # Middleware for Logging & Exception Handling
git clone https://github.com/yourusername/your-repo.git
cd your-repo
Update appsettings.json with your database connection string:
"ConnectionStrings": {
"DefaultConnection": "Server=your_server;Database=your_db;User Id=your_user;Password=your_password;"
}
dotnet ef database update
dotnet run --project WebApi
✅ Create a Tenant
POST /api/tenant/create
Request:
{
"name": "Company A"
}
✅ Create a User
POST /api/user/create
Request:
{
"name": "John Doe",
"email": "[email protected]",
"tenantId": "550e8400-e29b-41d4-a716-446655440000"
}
✅ Get Users by Tenant
GET /api/user/{tenantId}
✅ Update a User
PUT /api/user/update/{id}
✅ Delete a User
DELETE /api/user/delete/{id}
- .NET Core 8.0
- Entity Framework Core
- SQL Server (Stored Procedures)
- Middleware for Logging & Security
- Swagger (API Documentation)
This project is licensed under the MIT License.
- Fork the repository 🍴
- Create a new branch 📂 (
git checkout -b feature-branch
) - Commit your changes ✅ (
git commit -m 'Added new feature'
) - Push the branch 🚀 (
git push origin feature-branch
) - Create a Pull Request 🔄
🔹 Author: Bhavik Patel
🔹 GitHub: bhavikpatel99
🔹 Email: [email protected]