using OF_DL.Models.Dtos.Lists; using OF_DL.Models.Entities.Lists; namespace OF_DL.Models.Mappers; public static class UserListsMapper { public static UserList FromDto(UserListDto? dto) { UserList mapped = new() { HasMore = dto?.HasMore ?? false }; if (dto?.List == null) { return mapped; } foreach (UserListItemDto entry in dto.List) { mapped.List.Add(MapListItem(entry)); } return mapped; } public static List FromDto(List? dto) { if (dto == null) { return []; } return dto.Select(MapUsersList).ToList(); } private static UserListItem MapListItem(UserListItemDto dto) => new() { Id = dto.Id, Name = dto.Name }; private static UsersList MapUsersList(UsersListDto dto) => new() { Username = dto.Username }; }