48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using DoliMiddlewareApi.Dtos.Dolibarr;
|
|
using DoliMiddlewareApi.Dtos.query;
|
|
|
|
namespace DoliMiddlewareApi.Mappers;
|
|
|
|
public static class ContactMapper
|
|
{
|
|
public static ContactDto MapToContactDto(ContactResponse contactResponse)
|
|
{
|
|
return new ContactDto
|
|
{
|
|
Id = int.TryParse(contactResponse.id, out int id) ? id : 0,
|
|
Lastname = contactResponse.lastname,
|
|
Firstname = contactResponse.firstname,
|
|
Email = contactResponse.email,
|
|
PhonePro = contactResponse.phone_pro,
|
|
PhonePerso = contactResponse.phone_perso,
|
|
PhoneMobile = contactResponse.phone_mobile,
|
|
ClientId = int.TryParse(contactResponse.fk_soc, out int clientId) ? clientId : 0
|
|
};
|
|
}
|
|
|
|
public static ContactDetailDto MapToContactDetailDto(ContactResponse r)
|
|
{
|
|
return new ContactDetailDto
|
|
{
|
|
Id = int.TryParse(r.id, out int id) ? id : 0,
|
|
Lastname = r.lastname,
|
|
Firstname = r.firstname,
|
|
Email = r.email,
|
|
PhonePro = r.phone_pro,
|
|
PhonePerso = r.phone_perso,
|
|
PhoneMobile = r.phone_mobile,
|
|
ClientId = int.TryParse(r.fk_soc, out int clientId) ? clientId : 0,
|
|
Address = r.address,
|
|
Town = r.town,
|
|
Zip = r.zip,
|
|
CivilityCode = r.civility_code,
|
|
Status = r.statut switch
|
|
{
|
|
"0" => "inactive",
|
|
"1" => "active",
|
|
_ => r.statut
|
|
}
|
|
};
|
|
}
|
|
}
|