2026-01-30 15:34:23 +00:00
|
|
|
using DoliMiddlewareApi.Dtos.Dolibarr;
|
|
|
|
|
using DoliMiddlewareApi.Dtos.query;
|
|
|
|
|
|
|
|
|
|
namespace DoliMiddlewareApi.Mappers;
|
|
|
|
|
|
feat: add DTOs, Dolibarr response types and mappers for Contacts, Clients, Setup and invoice lines
- New command DTOs: CreateClientDto, UpdateClientDto, CreateContactDto,
UpdateContactDto, UpdateInvoiceLineDto
- New query DTOs: ClientDetailDto, ContactDetailDto, Setup dictionaries
(PaymentTypeDto, CountryDto, CivilityDto, ContactTypeDto,
PaymentTermDto, CompanyDto)
- New Dolibarr response types for setup endpoints
- SetupMapper for all dictionary transforms
- Extended ClientResponse and ContactResponse with additional fields
(address, town, zip, country_code, note_public, note_private, etc.)
- ClientMapper: added MapToClientDetailDto for GET /Clients/{id}
- ContactMapper: added MapToContactDetailDto for GET /Contacts/{id}
2026-05-15 16:58:26 +00:00
|
|
|
public static class ClientMapper
|
2026-01-30 15:34:23 +00:00
|
|
|
{
|
|
|
|
|
public static ClientDto MapToClientDto(ClientResponse clientResponse, List<ContactDto> contacts)
|
|
|
|
|
{
|
|
|
|
|
var clientId = int.TryParse(clientResponse.id, out int id) ? id : 0;
|
|
|
|
|
|
|
|
|
|
return new ClientDto
|
|
|
|
|
{
|
|
|
|
|
Id = clientId,
|
|
|
|
|
Name = clientResponse.name,
|
|
|
|
|
CodeClient = clientResponse.code_client,
|
2026-02-05 13:25:13 +00:00
|
|
|
TypentCode = clientResponse.typent_code,
|
|
|
|
|
Status = clientResponse.status,
|
|
|
|
|
Email = clientResponse.email,
|
|
|
|
|
Phone = clientResponse.phone,
|
2026-01-30 15:34:23 +00:00
|
|
|
Contacts = contacts.Where(c => c.ClientId == clientId).ToList()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ClientDto MapToClientDtoWithoutContacts(ClientResponse clientResponse)
|
|
|
|
|
{
|
|
|
|
|
return new ClientDto
|
|
|
|
|
{
|
|
|
|
|
Id = int.TryParse(clientResponse.id, out int id) ? id : 0,
|
|
|
|
|
Name = clientResponse.name,
|
2026-02-05 13:25:13 +00:00
|
|
|
CodeClient = clientResponse.code_client,
|
|
|
|
|
TypentCode = clientResponse.typent_code,
|
|
|
|
|
Status = clientResponse.status,
|
|
|
|
|
Email = clientResponse.email,
|
|
|
|
|
Phone = clientResponse.phone
|
2026-01-30 15:34:23 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
feat: add DTOs, Dolibarr response types and mappers for Contacts, Clients, Setup and invoice lines
- New command DTOs: CreateClientDto, UpdateClientDto, CreateContactDto,
UpdateContactDto, UpdateInvoiceLineDto
- New query DTOs: ClientDetailDto, ContactDetailDto, Setup dictionaries
(PaymentTypeDto, CountryDto, CivilityDto, ContactTypeDto,
PaymentTermDto, CompanyDto)
- New Dolibarr response types for setup endpoints
- SetupMapper for all dictionary transforms
- Extended ClientResponse and ContactResponse with additional fields
(address, town, zip, country_code, note_public, note_private, etc.)
- ClientMapper: added MapToClientDetailDto for GET /Clients/{id}
- ContactMapper: added MapToContactDetailDto for GET /Contacts/{id}
2026-05-15 16:58:26 +00:00
|
|
|
public static ClientDetailDto MapToClientDetailDto(ClientResponse r, List<ContactDto> contacts)
|
|
|
|
|
{
|
|
|
|
|
var clientId = int.TryParse(r.id, out int id) ? id : 0;
|
|
|
|
|
|
|
|
|
|
return new ClientDetailDto
|
|
|
|
|
{
|
|
|
|
|
Id = clientId,
|
|
|
|
|
Name = r.name ?? "",
|
|
|
|
|
CodeClient = r.code_client,
|
|
|
|
|
TypentCode = r.typent_code,
|
|
|
|
|
Status = r.status,
|
|
|
|
|
Email = r.email,
|
|
|
|
|
Phone = r.phone,
|
|
|
|
|
Address = r.address,
|
|
|
|
|
Town = r.town,
|
|
|
|
|
Zip = r.zip,
|
|
|
|
|
CountryCode = r.country_code,
|
|
|
|
|
VatNumber = r.tva_intra,
|
|
|
|
|
Url = r.url,
|
|
|
|
|
NotePublic = r.note_public,
|
|
|
|
|
NotePrivate = r.note_private,
|
|
|
|
|
Contacts = contacts.Where(c => c.ClientId == clientId).ToList()
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-01-30 15:34:23 +00:00
|
|
|
}
|