dotnet new webapi -n MovieRentalAPI
cd MovieRentalAPI
Install dependencies:
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
dotnet add package Swashbuckle.AspNetCore
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer
-
Models/→ define Movie, Customer, Rental with relationships. -
DTOs/→ define MovieDto, CustomerDto, RentalDto (for data transfer, avoiding exposing DB entities directly).
-
Define
ApplicationDbContext.csinData/ -
Configure DbSets for
Movies,Customers,Rentals -
Register DbContext in
Program.cswith PostgreSQL connection string.
Run migrations:
dotnet ef migrations add InitialCreate
dotnet ef database update
-
Create repository interfaces:
-
IMovieRepository -
ICustomerRepository -
IRentalRepository
-
-
Implement them in
Repositories/folder. -
Handle CRUD operations.
-
Create services:
-
MovieService -
CustomerService -
RentalService
-
-
Services call repositories and contain business logic.
-
Create controllers:
-
MoviesController -
CustomersController -
RentalsController
-
-
Map endpoints: CRUD operations + rental actions.
-
Use DTOs for input/output.
-
Add user registration/login (basic Identity or custom).
-
Configure JWT in
Program.cs. -
Add
[Authorize]attribute to controllers.
-
Configure Swagger to require JWT tokens.
-
Test API endpoints directly in Swagger.
-
Create a movie
-
Create a customer
-
Rent a movie
-
Return a movie
-
See rental history
-
Pagination and filtering
-
Role-based authorization (Admin/User)
-
Dockerize API and DB
-
Frontend integration (React/Angular)