This project is a user management service that allows for the creation, updating, deletion, and retrieval of user information. It is built on .NET Core and uses Entity Framework Core for data persistence. The API is documented with Swagger and can be accessed through the following endpoints.
To configure the project, the database connection string must be set in the appsettings.json or appsettings.Development.json file. The default connection string is Data Source=Users.db.
{
"ConnectionStrings": {
"Users": "Data Source=Users.db"
}
}This guide will walk you through the process of cloning the User Management Service repository and running it on your local machine. This will allow you to interact with the API and test its functionalities.
- .NET Core SDK installed. You can download it from here.
- A code editor or IDE, such as Visual Studio Code, which is recommended for this project.
Open your terminal or command prompt and navigate to the directory where you want to clone the repository. Then, run the following command:
git clone https://github.com/Sergioarg/usersAPI.gitAfter cloning the repository, navigate to the project directory:
cd usersAPIBefore running the project, you need to restore the dependencies. Run the following command:
dotnet restoreThe project uses SQLite as its database. Ensure you have SQLite installed on your machine. If not, you can download it from here.
The default connection string is Data Source=Users.db. You can configure this in the appsettings.json or appsettings.Development.json file if you wish to use a different database or connection string.
Before running the project, you need to apply the database migrations. This will create the necessary tables in your database. Run the following command:
dotnet ef database updateNow, you can run the project. Execute the following command:
dotnet run --project src/The application will start, and you should see output indicating that it's running. By default, the application runs on http://localhost:5155.
You can now access the API using your preferred tool (e.g., Postman, cURL, or a web browser) to interact with the endpoints as documented in the API documentation.
| Endpoint | Method | Description | Response | Request Body | Parameters |
|---|---|---|---|---|---|
/users |
GET | Retrieves a list of all users. | An array of User objects. |
N/A | N/A |
/users/{id} |
GET | Retrieves a specific user by their ID. | A User object or 404 Not Found if the user does not exist. |
N/A | id: The ID of the user. |
/users |
POST | Creates a new user. | 201 Created with the created User object and the location of the new resource. |
A User object. |
N/A |
/users/{id} |
PUT | Updates an existing user. | 204 No Content if the update is successful, or 404 Not Found if the user does not exist. |
A User object with the fields to update. |
id: The ID of the user to update. |
/users/{id} |
DELETE | Deletes a specific user by their ID. | 200 OK if the deletion is successful, or 404 Not Found if the user does not exist. |
N/A | id: The ID of the user to delete. |
To interact with the API, tools like Postman or cURL can be used. Below is an example of how to create a new user using cURL:
curl -X POST http://localhost:5155/users \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"birthdate": "1990-01-01",
"active": true
}'You can run the project of the project. Execute the following command:
dotnet test tests/The API documentation can be accessed through the Swagger UI interface at http://localhost:5155/swagger. Here, all available endpoints can be viewed, and tests can be performed directly from the browser.