This repository contains the source code for the Contact API, an ASP.NET Core application that manages contacts in an agenda. The API allows you to create, retrieve, edit, and delete contacts. Below are the usage instructions and details of the available routes.
- API_Contato.Context: Contains the Entity Framework context definition for the application.
- API_Contato.Entities: Defines domain entities, such as
Contato
. - API_Contato.Controllers: Contains controllers that expose the APIs for contact management.
- Route:
POST /contato
- Description: Creates a new contact.
- Parameters:
contato
: JSON object with contact information (Name, Phone, Active).
- Response:
200 OK
: Contact successfully created.400 Bad Request
: Error in creating contact.
- Route:
GET /contato/{id}
- Description: Retrieves a contact by ID.
- Parameters:
id
: Contact ID.
- Response:
200 OK
: Contact found.404 Not Found
: Contact not found.
- Route:
GET /contato/ObterPorNome
- Description: Retrieves contacts that contain the specified name.
- Parameters:
nome
: Name or part of the contact's name.
- Response:
200 OK
: List of contacts found.404 Not Found
: No contacts found.
- Route:
PUT /contato/{id}
- Description: Edits the information of a contact by ID.
- Parameters:
id
: Contact ID.contato
: JSON object with the updated contact information.
- Response:
200 OK
: Contact successfully edited.404 Not Found
: Contact not found.
- Route:
DELETE /contato/{id}
- Description: Deletes a contact by ID.
- Parameters:
id
: Contact ID.
- Response:
204 No Content
: Contact successfully deleted.404 Not Found
: Contact not found.
- .NET Core SDK
- Configured database (e.g., SQL Server, SQLite, etc.)
-
Clone the repository:
git clone https://github.com/your-username/ContactAPI.git cd ContactAPI
-
Configure the connection string in the
appsettings.json
file:"ConnectionStrings": { "DefaultConnection": "YourConnectionStringHere" }
-
Apply migrations to set up the database:
dotnet ef database update
To start the application, use the command:
dotnet run
This README.md
provides an overview of the API, describes the available endpoints, explains how to configure and run the application, and includes information on how to contribute and the project license.
Contributions are welcome! Feel free to open issues and pull requests for improvements and fixes.
This project is licensed under the MIT License.