This is an ASP.NET RESTful API that allows you to manage movies and genres. You can perform CRUD operations on movies and genres, including creating, retrieving, updating, and deleting movies and genres. You can also retrieve all movies, all movies in a certain genre, and a single movie by ID.
- .NET SKD 6.0
- Visual Studio
- SQL Server 2019 or later
- Clone the repository to your local machine
- Update the
DefaultConnection
string in theappsettings.json
file to point to your SQL Server instance - Run
Update-Database
command in thePackage Manager Console
to create the database - Build and run the solution
GET /api/movies
: Retrieve all moviesGET /api/movies/{id}
: Retrieve a single movie by IDGET /api/movies/GetAllInGenre?genreId={genreId}
: Retrieve all movies in a certain genrePOST /api/movies
: Create a new moviePUT /api/movies/{id}
: Update an existing movie by IDDELETE /api/movies/{id}
: Delete a movie by ID
GET /api/genres
: Retrieve all genresPOST /api/genres
: Create a new genrePUT /api/genres/{id}
: Update an existing genre by IDDELETE /api/genres/{id}
: Delete a genre by ID
POST /api/auth/register
: Register a new userPOST /api/auth/login
: Login and get a tokenPOST /api/auth/addusertorole
: Add a user to a role
GET /api/roles
: Retrieve all rolesPOST /api/roles
: Create a new rolePUT /api/roles/{id}
: Update an existing role by IDDELETE /api/roles/{id}
: Delete a role by ID
Authentication and authorization are implemented using JWT tokens. The API endpoints are protected by the [Authorize]
attribute, which requires a valid JWT token to access. The API uses Microsoft.AspNetCore.Authentication.JwtBearer
and Microsoft.IdentityModel.Tokens
libraries for authentication and authorization.
The API documentation is generated using Swagger. You can access the Swagger UI by navigating to /swagger
in your browser. The Swagger UI provides an interactive documentation for the API, including all endpoints, request/response schemas, and authentication information.