2026-01-30 15:34:23 +00:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
feat: add Contacts & Setup controllers, extend Clients/Invoices/Document controllers
- ContactsController: full CRUD (list, get, get by email, create, update, delete)
- SetupController: dictionary endpoints (payment-types, countries, civilities,
contact-types, payment-terms, company)
- ClientsController: added GET/{id}, POST, PUT/{id}, DELETE/{id}
- InvoicesController: added PUT/{id}/lines/{lineId}, GET /templates
- DocumentController: added GET /list and GET /download endpoints
- ClientService: added GetClientAsync, CreateClientAsync, UpdateClientAsync,
DeleteClientAsync
- InvoiceService: added UpdateInvoiceLineAsync, GetInvoiceTemplatesAsync
- DocumentService: added GetDocumentsAsync, DownloadDocumentAsync (using
new GetAsyncRaw on IDolibarrApiClient)
- ContactService: new service with CRUD operations
- SetupService: new service for Dolibarr dictionary data
- IDolibarrApiClient: added GetAsyncRaw method for raw string responses
- DolibarrApiClient: implemented GetAsyncRaw
- JwtTokenProvider: extended token expiry from 30 min to 8 hours
- AuthApplicationService: extended Dolibarr token cache from 30 min to 8 hours
2026-05-15 16:58:35 +00:00
|
|
|
using DoliMiddlewareApi.Dtos.command;
|
2026-01-30 15:34:23 +00:00
|
|
|
using DoliMiddlewareApi.Dtos.query;
|
|
|
|
|
using DoliMiddlewareApi.Services;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
feat: add Contacts & Setup controllers, extend Clients/Invoices/Document controllers
- ContactsController: full CRUD (list, get, get by email, create, update, delete)
- SetupController: dictionary endpoints (payment-types, countries, civilities,
contact-types, payment-terms, company)
- ClientsController: added GET/{id}, POST, PUT/{id}, DELETE/{id}
- InvoicesController: added PUT/{id}/lines/{lineId}, GET /templates
- DocumentController: added GET /list and GET /download endpoints
- ClientService: added GetClientAsync, CreateClientAsync, UpdateClientAsync,
DeleteClientAsync
- InvoiceService: added UpdateInvoiceLineAsync, GetInvoiceTemplatesAsync
- DocumentService: added GetDocumentsAsync, DownloadDocumentAsync (using
new GetAsyncRaw on IDolibarrApiClient)
- ContactService: new service with CRUD operations
- SetupService: new service for Dolibarr dictionary data
- IDolibarrApiClient: added GetAsyncRaw method for raw string responses
- DolibarrApiClient: implemented GetAsyncRaw
- JwtTokenProvider: extended token expiry from 30 min to 8 hours
- AuthApplicationService: extended Dolibarr token cache from 30 min to 8 hours
2026-05-15 16:58:35 +00:00
|
|
|
using Microsoft.AspNetCore.Http;
|
2026-01-30 15:34:23 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace DoliMiddlewareApi.Controllers;
|
|
|
|
|
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Route("api/[controller]")]
|
2026-02-03 16:19:53 +00:00
|
|
|
[Authorize]
|
2026-01-30 15:34:23 +00:00
|
|
|
public class ClientsController(ClientService clientService) : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
[HttpGet]
|
feat: add Contacts & Setup controllers, extend Clients/Invoices/Document controllers
- ContactsController: full CRUD (list, get, get by email, create, update, delete)
- SetupController: dictionary endpoints (payment-types, countries, civilities,
contact-types, payment-terms, company)
- ClientsController: added GET/{id}, POST, PUT/{id}, DELETE/{id}
- InvoicesController: added PUT/{id}/lines/{lineId}, GET /templates
- DocumentController: added GET /list and GET /download endpoints
- ClientService: added GetClientAsync, CreateClientAsync, UpdateClientAsync,
DeleteClientAsync
- InvoiceService: added UpdateInvoiceLineAsync, GetInvoiceTemplatesAsync
- DocumentService: added GetDocumentsAsync, DownloadDocumentAsync (using
new GetAsyncRaw on IDolibarrApiClient)
- ContactService: new service with CRUD operations
- SetupService: new service for Dolibarr dictionary data
- IDolibarrApiClient: added GetAsyncRaw method for raw string responses
- DolibarrApiClient: implemented GetAsyncRaw
- JwtTokenProvider: extended token expiry from 30 min to 8 hours
- AuthApplicationService: extended Dolibarr token cache from 30 min to 8 hours
2026-05-15 16:58:35 +00:00
|
|
|
[ProducesResponseType(typeof(List<ClientDto>), StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
public async Task<ActionResult<List<ClientDto>>> GetClients(
|
2026-01-30 15:34:23 +00:00
|
|
|
[FromQuery] int limit = 50,
|
2026-05-16 22:01:26 +00:00
|
|
|
[FromQuery][Range(1, int.MaxValue)] int page = 1,
|
|
|
|
|
[FromQuery] bool supplier = false)
|
2026-01-30 15:34:23 +00:00
|
|
|
{
|
2026-05-16 22:01:26 +00:00
|
|
|
var clients = await clientService.GetClientsAsync(limit, page, supplier);
|
2026-01-30 15:34:23 +00:00
|
|
|
return Ok(clients);
|
|
|
|
|
}
|
2026-02-03 16:19:53 +00:00
|
|
|
|
feat: add Contacts & Setup controllers, extend Clients/Invoices/Document controllers
- ContactsController: full CRUD (list, get, get by email, create, update, delete)
- SetupController: dictionary endpoints (payment-types, countries, civilities,
contact-types, payment-terms, company)
- ClientsController: added GET/{id}, POST, PUT/{id}, DELETE/{id}
- InvoicesController: added PUT/{id}/lines/{lineId}, GET /templates
- DocumentController: added GET /list and GET /download endpoints
- ClientService: added GetClientAsync, CreateClientAsync, UpdateClientAsync,
DeleteClientAsync
- InvoiceService: added UpdateInvoiceLineAsync, GetInvoiceTemplatesAsync
- DocumentService: added GetDocumentsAsync, DownloadDocumentAsync (using
new GetAsyncRaw on IDolibarrApiClient)
- ContactService: new service with CRUD operations
- SetupService: new service for Dolibarr dictionary data
- IDolibarrApiClient: added GetAsyncRaw method for raw string responses
- DolibarrApiClient: implemented GetAsyncRaw
- JwtTokenProvider: extended token expiry from 30 min to 8 hours
- AuthApplicationService: extended Dolibarr token cache from 30 min to 8 hours
2026-05-15 16:58:35 +00:00
|
|
|
[HttpGet("{id:int}")]
|
|
|
|
|
[ProducesResponseType(typeof(ClientDetailDto), StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
public async Task<ActionResult<ClientDetailDto>> GetClient([Range(1, int.MaxValue)] int id)
|
|
|
|
|
{
|
|
|
|
|
var client = await clientService.GetClientAsync(id);
|
|
|
|
|
return Ok(client);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ProducesResponseType(typeof(int), StatusCodes.Status201Created)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
public async Task<ActionResult<int>> CreateClient([FromBody] CreateClientDto dto)
|
|
|
|
|
{
|
|
|
|
|
var clientId = await clientService.CreateClientAsync(dto);
|
|
|
|
|
return CreatedAtAction(nameof(GetClient), new { id = clientId }, clientId);
|
|
|
|
|
}
|
2026-02-03 16:19:53 +00:00
|
|
|
|
feat: add Contacts & Setup controllers, extend Clients/Invoices/Document controllers
- ContactsController: full CRUD (list, get, get by email, create, update, delete)
- SetupController: dictionary endpoints (payment-types, countries, civilities,
contact-types, payment-terms, company)
- ClientsController: added GET/{id}, POST, PUT/{id}, DELETE/{id}
- InvoicesController: added PUT/{id}/lines/{lineId}, GET /templates
- DocumentController: added GET /list and GET /download endpoints
- ClientService: added GetClientAsync, CreateClientAsync, UpdateClientAsync,
DeleteClientAsync
- InvoiceService: added UpdateInvoiceLineAsync, GetInvoiceTemplatesAsync
- DocumentService: added GetDocumentsAsync, DownloadDocumentAsync (using
new GetAsyncRaw on IDolibarrApiClient)
- ContactService: new service with CRUD operations
- SetupService: new service for Dolibarr dictionary data
- IDolibarrApiClient: added GetAsyncRaw method for raw string responses
- DolibarrApiClient: implemented GetAsyncRaw
- JwtTokenProvider: extended token expiry from 30 min to 8 hours
- AuthApplicationService: extended Dolibarr token cache from 30 min to 8 hours
2026-05-15 16:58:35 +00:00
|
|
|
[HttpPut("{id:int}")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
public async Task<IActionResult> UpdateClient([Range(1, int.MaxValue)] int id, [FromBody] UpdateClientDto dto)
|
|
|
|
|
{
|
|
|
|
|
await clientService.UpdateClientAsync(id, dto);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
2026-02-03 16:19:53 +00:00
|
|
|
|
feat: add Contacts & Setup controllers, extend Clients/Invoices/Document controllers
- ContactsController: full CRUD (list, get, get by email, create, update, delete)
- SetupController: dictionary endpoints (payment-types, countries, civilities,
contact-types, payment-terms, company)
- ClientsController: added GET/{id}, POST, PUT/{id}, DELETE/{id}
- InvoicesController: added PUT/{id}/lines/{lineId}, GET /templates
- DocumentController: added GET /list and GET /download endpoints
- ClientService: added GetClientAsync, CreateClientAsync, UpdateClientAsync,
DeleteClientAsync
- InvoiceService: added UpdateInvoiceLineAsync, GetInvoiceTemplatesAsync
- DocumentService: added GetDocumentsAsync, DownloadDocumentAsync (using
new GetAsyncRaw on IDolibarrApiClient)
- ContactService: new service with CRUD operations
- SetupService: new service for Dolibarr dictionary data
- IDolibarrApiClient: added GetAsyncRaw method for raw string responses
- DolibarrApiClient: implemented GetAsyncRaw
- JwtTokenProvider: extended token expiry from 30 min to 8 hours
- AuthApplicationService: extended Dolibarr token cache from 30 min to 8 hours
2026-05-15 16:58:35 +00:00
|
|
|
[HttpDelete("{id:int}")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
public async Task<IActionResult> DeleteClient([Range(1, int.MaxValue)] int id)
|
|
|
|
|
{
|
|
|
|
|
await clientService.DeleteClientAsync(id);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
}
|