Files
weddingapi/Converters/Extensions.cs
2022-05-14 20:19:41 +02:00

47 lines
1.2 KiB
C#

using System.Linq;
using weddingapi.Dtos;
using weddingapi.Models;
namespace weddingapi.Converters
{
public static class Converters
{
public static FamilyDto AsDto(this Family family)
{
return new FamilyDto()
{
Id = family.Id,
CreatedDate = family.CreatedDate,
Overnight = family.Overnight,
Email = family.Email,
Telephonenumber = family.Telephonenumber,
Members = family.Members.Select(person => person.AsDto()).ToList(),
Name = family.Name,
};
}
public static PersonDto AsDto(this Person person)
{
return new PersonDto()
{
IsChild = person.IsChild,
Name = person.Name,
};
}
public static ContactDto AsDto(this Contact contact)
{
return new ContactDto()
{
CreatedDate = contact.CreatedDate,
Email = contact.Email,
From = contact.From,
Id = contact.Id,
Message = contact.Message,
};
}
}
}