🇬🇧 This repository contains a study project of a Web API using .NET 7 with the goal of implementing CRUD (Create, Read, Update, Delete) functionalities for users, including JWT Bearer authentication and secure password storage.
🇧🇷 Este repositório contém um projeto de estudo da criação de uma API web em .NET 7 com o objetivo de implementar um CRUD completo (Create, Read, Update, Delete) de usuários, incluindo autenticação com JWT Bearer Authentication e armazenamento seguro de senhas.
Method | Route | JSON Body | Action |
---|---|---|---|
POST | /Login | Email + Password | Generates the access token |
POST | /User | Name + Email + Password | Creates the user |
GET | /User?offset=5&limit=5 | Returns the list of users | |
GET | /User/Id/{id} | Returns the user of the id | |
GET | /User/Email/{email} | Returns the user of the email | |
PUT | /User/UpdateName | Id + Name | Updates the user's name |
PUT | /User/UpdateEmail | Id + Email | Updates the user's email |
PUT | /User/UpdatePassword | Id + Password | Updates the user's password |
DELETE | /User/Delete/{id} | Deletes the user |
{
"name": "string",
"email": "string",
"password": "string"
}
{
"data": {
"id": 0,
"name": "string",
"email": "string"
},
"message": "string",
"statusCode": 100,
"error": "string"
}
To run the application, you must have these tools installed:
Download or clone the project from: https://github.com/MatheusMGrassano/WebApiUsers.git
Change the database connection credentials in the appsettings.json file.
Set the "Data Source" of the connection string using your SQL Server's name and in the "DataBase" choose a name for the database that will be created.
ConnectionString example:
"ConnectionStrings": {
"Default": "Data Source=YourServer;Database=YourDatabase;Trusted_connection=true;Encrypt=false;TrustServerCertificate=true"
}
At your terminal, access the project's root folder and type the following commands:
dotnet tool install --global dotnet-ef
dotnet ef migrations add DataBaseCreation
dotnet ef database update
At your terminal, access the project's root folder and type the following command:
dotnet watch run
Then, a new browser tab will open with the Swagger UI, showing all the features of the API.