2
0
forked from sim0n00ps/OF-DL
OF-DL/OF DL.Core/Models/Mappers/SubscriptionsMapper.cs

28 lines
678 B
C#

using OF_DL.Models.Dtos.Subscriptions;
using OF_DL.Models.Entities.Subscriptions;
namespace OF_DL.Models.Mappers;
public static class SubscriptionsMapper
{
public static Subscriptions FromDto(SubscriptionsDto? dto)
{
Subscriptions mapped = new() { HasMore = dto?.HasMore ?? false };
if (dto?.List == null)
{
return mapped;
}
foreach (ListItemDto entry in dto.List)
{
mapped.List.Add(MapList(entry));
}
return mapped;
}
private static ListItem MapList(ListItemDto dto) =>
new() { Id = dto.Id, Username = dto.Username ?? "", IsRestricted = dto.IsRestricted };
}