This is a simple ASP.NET Core Web API application for managing banks and bank accounts. The application is built using .NET 8 and Entity Framework Core.
- Manage banks (Create, Read, Update, Delete)
- Manage bank accounts (Create, Read, Update, Delete)
- Swagger UI for API documentation and testing
- CORS support
- Clone the repository:
-git clone
https://github.com/Collins0399/Bank-API.git
The API provides the following endpoints:
GET /api/Bank- Get all banksGET /api/Bank/{id}- Get a bank by IDPOST /api/Bank- Create a new bankPUT /api/Bank/{id}- Update a bankDELETE /api/Bank/{id}- Delete a bank
GET /api/BankAccount- Get all bank accountsGET /api/BankAccount/{id}- Get a bank account by IDPOST /api/BankAccount- Create a new bank accountPUT /api/BankAccount/{id}- Update a bank accountDELETE /api/BankAccount/{id}- Delete a bank account
You can access the Swagger UI for testing the API endpoints at https://localhost:7187/swagger.
To test the API endpoints using Postman, follow these steps:
-
Set Up Postman:
- Download and install Postman from here.
- Open Postman and create a new collection for your API tests.
-
Add Requests to the Collection:
- For each endpoint, create a new request in Postman.
-
Get All Banks
- Method: GET
- URL:
https://localhost:7187/api/Bank - Description: Retrieves a list of all banks.
-
Get Bank by ID
- Method: GET
- URL:
https://localhost:7187/api/Bank/{id} - Description: Retrieves a bank by its ID.
- Parameters:
id(path parameter): The ID of the bank to retrieve.
-
Create a New Bank
- Method: POST
- URL:
https://localhost:7187/api/Bank - Description: Creates a new bank.
- Body (JSON):
-**Get All Bank Accounts
-**Method: GET
-**URL: https://localhost:7187/api/BankAccount
-**Description: Retrieves a list of all bank accounts.
-**Get Bank Account by ID
-**Method: GET
-**URL: https://localhost:7187/api/BankAccount/{id}
-**Description: Retrieves a bank account by its ID.
-**Parameters:
-**id (path parameter): The ID of the bank account to retrieve.
-**Create a New Bank Account -**Method: POST
-
URL:
https://localhost:7187/api/BankAccount-**Description: Creates a new bank account. -Body (JSON): -{ "accountNumber": "123456789", "bankId": 1, //other properties } -
Delete a Bank Account
- Method: DELETE
- URL:
https://localhost:7187/api/BankAccount/{id} - Description: Deletes a bank account by its ID.
- Parameters:
id(path parameter): The ID of the bank account to delete.
Controllers- Contains the API controllers for handling HTTP requests.Models- Contains the data models and the Entity Framework Core DB context.Program.cs- The entry point of the application.
appsettings.json- Contains the configuration settings for the application.appsettings.Development.json- Contains the development-specific configuration settings.
Contributions are welcome! Please open an issue or submit a pull request.