đ§ ClientController Documentation
đ§ QUICK DOCUMENTATIONâ
- File Path: /API/Controllers/ClientController.cs
- Primary Purpose: Manages client entities within the system, including client information, associated users, administrators, and documents.
- Key Endpoints:
- đ GET /List - Retrieves list of clients
- đ GET /Get - Gets a specific client by ID
- đ POST /Update - Updates client details
- âī¸ POST /AddUser - Associates a user with a client
- đī¸ POST /RemoveUser - Removes a user from a client
- âī¸ POST /SearchClients - Searches for clients based on criteria
- âī¸ POST /AddDocument - Adds a document to a client
- Related Models: ClientDto, ClientSummaryDto, ClientDetailDto
- Used By:
- Administration screens
- User management interfaces
- Client management dashboards
- Multi-tenancy functionality
đī¸ DETAILED DOCUMENTATIONâ
đī¸ Overviewâ
The ClientController manages client entities in Asset Valuer Pro's multi-tenant architecture. Clients represent organizations using the system, each with their own set of users, administrators, documents, and associated data. This controller handles all aspects of client management, including creation, retrieval, updating, user assignment, and document management. Access to this controller is restricted to users with the Administrator role.
đ§ Controller Dependenciesâ
- Namespace: AVP.API.Controllers
- Services Used:
- Mediator (CQRS pattern implementation)
- Other Dependencies:
- Authorization attribute requiring the Administrator role
đ Endpointsâ
đ List Clients By Groupâ
- HTTP Method: GET
- URL Pattern: /List
- Authentication: đ Required (Administrator role only)
- Description: Retrieves a list of clients, optionally filtered by group ID
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | GetClientListQuery | Yes | Optional GroupId to filter clients |
Response Formatâ
[
{
"id": 123,
"name": "City Council XYZ",
"groupId": 456,
"groupName": "Government",
"contactPerson": "John Smith",
"email": "jsmith@cityxyz.gov",
"phone": "555-123-4567",
"status": "Active",
"numberOfJobs": 5,
"numberOfUsers": 8
},
{
"id": 124,
"name": "ABC Corporation",
"groupId": 789,
"groupName": "Corporate",
"contactPerson": "Jane Doe",
"email": "jdoe@abccorp.com",
"phone": "555-987-6543",
"status": "Active",
"numberOfJobs": 3,
"numberOfUsers": 4
}
]
đ List Clients By User IDâ
- HTTP Method: GET
- URL Pattern: /ListByUserId
- Authentication: đ Required (Administrator role only)
- Description: Retrieves a list of clients associated with a specific user
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | GetClientListByUserIdQuery | Yes | Contains UserId to filter clients |
Response Formatâ
[
{
"id": 123,
"name": "City Council XYZ",
"groupId": 456,
"groupName": "Government",
"contactPerson": "John Smith",
"email": "jsmith@cityxyz.gov",
"phone": "555-123-4567",
"status": "Active",
"numberOfJobs": 5,
"numberOfUsers": 8
}
]
đ Get Client Detailâ
- HTTP Method: GET
- URL Pattern: /GetDetail
- Authentication: đ Required (Administrator role only)
- Description: Retrieves detailed information about a specific client
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | GetClientDetailQuery | Yes | Contains ClientId to retrieve |
Response Formatâ
{
"id": 123,
"name": "City Council XYZ",
"groupId": 456,
"groupName": "Government",
"address": "123 Main St, City XYZ",
"contactPerson": "John Smith",
"email": "jsmith@cityxyz.gov",
"phone": "555-123-4567",
"status": "Active",
"createdDate": "2024-01-15T00:00:00Z",
"lastModifiedDate": "2025-03-10T00:00:00Z",
"numberOfJobs": 5,
"numberOfUsers": 8,
"subscriptionDetails": {
"planType": "Enterprise",
"startDate": "2024-01-01T00:00:00Z",
"expiryDate": "2026-01-01T00:00:00Z",
"features": ["EasySAM", "Multi-User", "Custom Reports"]
},
"users": [
{
"id": "user123",
"name": "Sarah Johnson",
"email": "sjohnson@cityxyz.gov",
"role": "User"
},
{
"id": "user456",
"name": "Mike Brown",
"email": "mbrown@cityxyz.gov",
"role": "Administrator"
}
],
"documents": [
{
"id": "doc123",
"fileName": "Service Agreement.pdf",
"uploadDate": "2024-02-15T00:00:00Z",
"uploadedBy": "Admin User"
}
]
}
đ Get Clientâ
- HTTP Method: GET
- URL Pattern: /Get
- Authentication: đ Required (Administrator role only)
- Description: Retrieves basic information about a specific client
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | GetClientQuery | Yes | Contains ClientId to retrieve |
Response Formatâ
{
"id": 123,
"name": "City Council XYZ",
"groupId": 456,
"address": "123 Main St, City XYZ",
"contactPerson": "John Smith",
"email": "jsmith@cityxyz.gov",
"phone": "555-123-4567",
"status": "Active"
}
đ Update Clientâ
- HTTP Method: POST
- URL Pattern: /Update
- Authentication: đ Required (Administrator role only)
- Description: Updates client information or creates a new client
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| command | UpdateClientCommand | Yes | Contains client data to update |
Response Formatâ
{
"id": 123,
"name": "City Council XYZ (Updated)",
"groupId": 456,
"address": "456 New St, City XYZ",
"contactPerson": "John Smith",
"email": "jsmith@cityxyz.gov",
"phone": "555-123-4567",
"status": "Active"
}
âī¸ Search Clientsâ
- HTTP Method: POST
- URL Pattern: /SearchClients
- Authentication: đ Required (Administrator role only)
- Description: Searches for clients based on various criteria
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | SearchClientsQuery | Yes | Search criteria for clients |
Response Formatâ
[
{
"id": 123,
"name": "City Council XYZ",
"groupId": 456,
"groupName": "Government",
"contactPerson": "John Smith",
"email": "jsmith@cityxyz.gov",
"phone": "555-123-4567",
"status": "Active",
"numberOfJobs": 5,
"numberOfUsers": 8
}
]
âī¸ Add Userâ
- HTTP Method: POST
- URL Pattern: /AddUser
- Authentication: đ Required (Administrator role only)
- Description: Associates a user with a client
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| command | AddUserCommand | Yes | Contains ClientId and UserId to associate |
Response Formatâ
{
"id": 123,
"name": "City Council XYZ",
"groupId": 456,
"address": "123 Main St, City XYZ",
"contactPerson": "John Smith",
"email": "jsmith@cityxyz.gov",
"phone": "555-123-4567",
"status": "Active"
}
đī¸ Remove Userâ
- HTTP Method: POST
- URL Pattern: /RemoveUser
- Authentication: đ Required (Administrator role only)
- Description: Removes a user from a client
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| command | RemoveUserCommand | Yes | Contains ClientId and UserId to disassociate |
Response Formatâ
{
"id": 123,
"name": "City Council XYZ",
"groupId": 456,
"address": "123 Main St, City XYZ",
"contactPerson": "John Smith",
"email": "jsmith@cityxyz.gov",
"phone": "555-123-4567",
"status": "Active"
}
âī¸ Add Administratorâ
- HTTP Method: POST
- URL Pattern: /AddAdministrator
- Authentication: đ Required (Administrator role only)
- Description: Designates a user as an administrator for a client
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| command | AddClientAdministratorCommand | Yes | Contains ClientId and UserId to make administrator |
Response Formatâ
{
"id": 123,
"name": "City Council XYZ",
"groupId": 456,
"address": "123 Main St, City XYZ",
"contactPerson": "John Smith",
"email": "jsmith@cityxyz.gov",
"phone": "555-123-4567",
"status": "Active"
}
đī¸ Remove Administratorâ
- HTTP Method: POST
- URL Pattern: /RemoveAdministrator
- Authentication: đ Required (Administrator role only)
- Description: Removes administrator status from a user for a client
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| command | RemoveClientAdministratorCommand | Yes | Contains ClientId and UserId to remove administrator status |
Response Formatâ
{
"id": 123,
"name": "City Council XYZ",
"groupId": 456,
"address": "123 Main St, City XYZ",
"contactPerson": "John Smith",
"email": "jsmith@cityxyz.gov",
"phone": "555-123-4567",
"status": "Active"
}
âī¸ Add Documentâ
- HTTP Method: POST
- URL Pattern: /AddDocument
- Authentication: đ Required (Administrator role only)
- Description: Adds a document to a client
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| command | AddDocumentCommand | Yes | Contains ClientId and document file to upload |
Response Formatâ
{
"message": "Document successfully uploaded"
}
đī¸ Remove Documentâ
- HTTP Method: POST
- URL Pattern: /RemoveDocument
- Authentication: đ Required (Administrator role only)
- Description: Removes a document from a client
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| command | RemoveDocumentCommand | Yes | Contains ClientId and DocumentId to remove |
Response Formatâ
{
"message": "Document successfully removed"
}
đ Get Documentâ
- HTTP Method: POST
- URL Pattern: /GetDocument
- Authentication: đ Required (Administrator role only)
- Description: Retrieves a document associated with a client
Request Parametersâ
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | GetDocumentQuery | Yes | Contains ClientId and DocumentId to retrieve |
Response Formatâ
File download (binary content)
đī¸ Multi-Tenant Architectureâ
âšī¸ Note: The ClientController is central to AVP's multi-tenant architecture:
-
Client Isolation
- Each client's data is logically separated
- Users are associated with specific clients
- Assets, jobs, and related data belong to clients
- Ensures data privacy and security
-
User Assignment
- Users can be assigned to one or more clients
- Client administrators can manage their users
- System administrators can manage all clients
- Role-based permissions within each client context
-
Document Management
- Client-specific document storage
- Contract and agreement management
- Service documentation
- Audit and compliance evidence
đ Security Considerationsâ
The ClientController implements several security measures:
-
Role-Based Access
- Only users with Administrator role can access endpoints
- Client-specific administrators have limited access to their client
- System administrators have access to all clients
-
Data Isolation
- Queries automatically filter by client context
- Cross-client data access is prevented
- User-client relationships enforce data boundaries
-
Audit Trails
- All client modifications are logged
- User-client assignments are tracked
- Document uploads and removals are recorded