Skip to main content

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:
https://your-domain.com/api
All endpoints are prefixed with /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

/api/lockers

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 the LockerInfo object with the following structure:
{
  "lockerNo": "string",
  "employeeNumber": "string",
  "size": 0,
  "location": "string",
  "isEmpty": true
}
FieldTypeDescription
lockerNostringUnique identifier for the locker (Primary Key)
employeeNumberstringEmployee number assigned to the locker (nullable)
sizeintegerSize of the locker
locationstringPhysical location of the locker
isEmptybooleanIndicates whether the locker is available

HTTP Status Codes

The API uses standard HTTP status codes:
Status CodeDescription
200 OKRequest successful
201 CreatedResource successfully created
400 Bad RequestInvalid request or validation error
404 Not FoundResource not found
500 Internal Server ErrorServer 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 Found
"Locker not found"
400 Bad Request
{
  "message": "Employee number {number} already exists"
}
{
  "message": "Locker number {number} already exists"
}

Swagger 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:
  1. Run the API in development mode
  2. Navigate to /swagger in your browser
  3. 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 under LockersDbConnectionString.

Getting Started

To start using the API:
  1. Ensure the API is running and accessible
  2. Review the available endpoints in the cards above
  3. Make HTTP requests to the appropriate endpoints
  4. Handle responses according to the HTTP status codes
For detailed information about each endpoint, click on the respective cards above or navigate to the specific endpoint documentation pages.

Build docs developers (and LLMs) love