Invoice Management System is an ASP.NET Core Web API developed using .NET 8 and SQL Server.
- JWT-based User Authentication
- Password Hashing
- Role-Based Permission System with database-driven permissions
- Invoice Create, View, Update and Delete
- Auto-generated Invoice Numbers
- Pagination
- Search
- Sorting
- Soft Delete
- Global Exception Handling
- Input Validation
- EF Core Code First Migrations
- Dependency Injection
- Repository and Service Pattern
- Async/Await
- ASP.NET Core Web API (.NET 8)
- Entity Framework Core
- SQL Server
- JWT Authentication
- Swagger / OpenAPI
- Controllers - API endpoints
- Services - Business logic
- Repositories - Data access logic
- Interfaces - Service and repository contracts
- Models - Database entities
- DTOs - Request and response models
- Filters - Permission authorization
- Middleware - Global exception handling
- Data - EF Core DbContext
- Migrations - Database migrations
This project uses Entity Framework Core Code First.
Update appsettings.json:
"ConnectionStrings": {
"dbcs": "YOUR_CONNECTION_STRING"
}Example using Windows Authentication:
Server=YOUR_SERVER_NAME;Database=InvoiceManagementDB;Trusted_Connection=True;TrustServerCertificate=True;
Update the JWT key in appsettings.json:
"Jwt": {
"Key": "YOUR_SECRET_KEY_MINIMUM_32_CHARACTERS",
"Issuer": "InvoiceManagementSystem",
"Audience": "InvoiceManagementSystemUsers",
"ExpiryMinutes": 60
}Use a secure random secret key of at least 32 characters.
Open Package Manager Console and run:
Update-DatabaseEF Core migrations will create the required database tables and seed the initial roles and permissions.
Admin has the following permissions:
- ViewInvoice
- CreateInvoice
- UpdateInvoice
- DeleteInvoice
User has:
- ViewInvoice
Register a user using:
POST /api/Auth/register
Login using:
POST /api/Auth/login
The Login API returns a JWT token.
Use the token through Swagger's Authorize option to access protected endpoints.
POST /api/Invoice
GET /api/Invoice
GET /api/Invoice/{id}
PUT /api/Invoice/{id}
DELETE /api/Invoice/{id}
The GET endpoint supports pagination, search and sorting through query parameters.
Example:
GET /api/Invoice?pageNumber=1&pageSize=10&search=Amit&sortBy=amount&sortDescending=false
A valid JWT token is required for Invoice APIs.
Admin users can create, view, update and delete invoices.
Normal users have ViewInvoice permission only.
Requests without valid authentication return 401 Unauthorized.
Authenticated users without the required permission return 403 Forbidden.
- Clone or download the repository.
- Open the solution in Visual Studio.
- Configure the SQL Server connection string.
- Configure a secure JWT secret key.
- Run
Update-Database. - Build and run the application.
- Open Swagger to test the APIs.