add supplier attributes
This commit is contained in:
54
AB.Services/Converter/CommunicationTypeConverter.cs
Normal file
54
AB.Services/Converter/CommunicationTypeConverter.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using AB.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Services.Converter;
|
||||
|
||||
internal class CommunicationTypeConverter
|
||||
{
|
||||
|
||||
public static CommunicationType ConvertFromBusinessValue
|
||||
(Domain.Enums.CommunicationType communicationType)
|
||||
{
|
||||
switch (communicationType)
|
||||
{
|
||||
case Domain.Enums.CommunicationType.Email:
|
||||
return CommunicationType.Email;
|
||||
case Domain.Enums.CommunicationType.Phone:
|
||||
return CommunicationType.Phone;
|
||||
case Domain.Enums.CommunicationType.Postal:
|
||||
return CommunicationType.Postal;
|
||||
case Domain.Enums.CommunicationType.Fax:
|
||||
return CommunicationType.Fax;
|
||||
default:
|
||||
var ex = new ArgumentException(
|
||||
$"Invalid Type of {nameof(Domain.Enums.CommunicationType)}: {communicationType}",
|
||||
nameof(communicationType));
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public static Domain.Enums.CommunicationType ConvertToBusinessValue
|
||||
(CommunicationType communicationType)
|
||||
{
|
||||
switch (communicationType)
|
||||
{
|
||||
case CommunicationType.Email:
|
||||
return Domain.Enums.CommunicationType.Email;
|
||||
case CommunicationType.Postal:
|
||||
return Domain.Enums.CommunicationType.Postal;
|
||||
case CommunicationType.Fax:
|
||||
return Domain.Enums.CommunicationType.Fax;
|
||||
case CommunicationType.Phone:
|
||||
return Domain.Enums.CommunicationType.Phone;
|
||||
default:
|
||||
var ex = new ArgumentException(
|
||||
$"Invalid Type of {nameof(Domain.Enums.CommunicationType)}: {communicationType}",
|
||||
nameof(communicationType));
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
AB.Services/Converter/ContactPersonConverter.cs
Normal file
44
AB.Services/Converter/ContactPersonConverter.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using AB.Contracts;
|
||||
using AB.Domain.Entities;
|
||||
|
||||
namespace AB.Services.Converter;
|
||||
|
||||
internal static class ContactPersonConverter
|
||||
{
|
||||
|
||||
public static ContactPersonDto ConvertToDto(this ContactPerson contactPerson)
|
||||
{
|
||||
var dto = new ContactPersonDto
|
||||
{
|
||||
Salutation = contactPerson.Salutation,
|
||||
Name = contactPerson.Name,
|
||||
Email = contactPerson.Email,
|
||||
PhoneNumer = contactPerson.PhoneNumber,
|
||||
Notes = contactPerson.Notes,
|
||||
};
|
||||
return dto;
|
||||
}
|
||||
|
||||
public static ContactPerson ConvertToBusinessType(this ContactPersonDto dto)
|
||||
{
|
||||
var contactPerson = new ContactPerson
|
||||
{
|
||||
Salutation = dto.Salutation,
|
||||
Name = dto.Name,
|
||||
Email = dto.Email,
|
||||
PhoneNumber = dto.PhoneNumer,
|
||||
Notes = dto.Notes,
|
||||
};
|
||||
return contactPerson;
|
||||
}
|
||||
|
||||
public static List<ContactPerson> ConvertToContactPersonList(this IEnumerable<ContactPersonDto> contactPersons)
|
||||
{
|
||||
return contactPersons.Select(x => x.ConvertToBusinessType()).ToList();
|
||||
}
|
||||
|
||||
public static IEnumerable<ContactPersonDto> ConvertToContactPersonDtoList(this List<ContactPerson> contactPersons)
|
||||
{
|
||||
return contactPersons.Select(x => x.ConvertToDto());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user