Introduction
The Locker Management API is a RESTful service built with .NET Core 6.0 that provides comprehensive functionality for managing locker assignments and availability. This API enables you to create, read, update, and delete locker records, as well as track employee assignments and locker availability.Base URL
The API is accessible at:/api/lockers.
Authentication
This API currently does not require authentication. All endpoints are publicly accessible. CORS is enabled with a permissive policy that allows any origin, method, and header.In a production environment, it is recommended to implement proper authentication and restrict CORS to specific origins.
API Structure
The API follows REST conventions with the base route/api/lockers. All endpoints use standard HTTP methods (GET, POST, PUT, DELETE) and return JSON responses.
Base Route
Available Endpoints
Get All Lockers
Retrieve a list of all lockers, ordered by locker number
Get Locker
Retrieve details of a specific locker by locker number
Add Locker
Create a new locker entry in the system
Update Locker
Update an existing locker’s information
Delete Locker
Remove a locker from the system
Response Format
All API responses are returned in JSON format. The API uses standard HTTP status codes to indicate the success or failure of requests.Locker Object
The primary data model is theLockerInfo object with the following structure:
| Field | Type | Description |
|---|---|---|
lockerNo | string | Unique identifier for the locker (Primary Key) |
employeeNumber | string | Employee number assigned to the locker (nullable) |
size | integer | Size of the locker |
location | string | Physical location of the locker |
isEmpty | boolean | Indicates whether the locker is available |
HTTP Status Codes
The API uses standard HTTP status codes:| Status Code | Description |
|---|---|
200 OK | Request successful |
201 Created | Resource successfully created |
400 Bad Request | Invalid request or validation error |
404 Not Found | Resource not found |
500 Internal Server Error | Server error |
Error Handling
When an error occurs, the API returns an appropriate HTTP status code along with an error message.Common Error Responses
404 Not FoundSwagger Documentation
Interactive API documentation is available via Swagger UI when running in development mode. Swagger provides a user-friendly interface to explore and test all API endpoints. To access Swagger:- Run the API in development mode
- Navigate to
/swaggerin your browser - Use the interactive UI to test endpoints
Swagger UI is only available in the development environment for security purposes.
Database
The API uses SQL Server with Entity Framework Core for data persistence. The connection string is configured in the application settings underLockersDbConnectionString.
Getting Started
To start using the API:- Ensure the API is running and accessible
- Review the available endpoints in the cards above
- Make HTTP requests to the appropriate endpoints
- Handle responses according to the HTTP status codes