Files
monorepo/LCU.API.Collections.RepoApi-old/LCU.API.Collections.RepoApi/Formatting/DataTableFormatting.cs
T
2026-04-20 14:47:24 -05:00

26 lines
863 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using LCU.API.Collections.RepoApi.Models.Reporting;
using LCU.Shared.Collections.RepoApiLib.Models.Reporting.Responses;
namespace LCU.Shared.Collections.RepoApiLib.Formatting
{
public static class DataTableFormatting
{
public static DataTable CreateDataTable<T>(IEnumerable<T> dataRows, Func<T, int> repoID, params Func<T, ReportHeaderCellMap>[] columns)
{
return new DataTable()
{
Headers = columns.Select(column => column(default(T)).Header).ToArray(),
Rows = dataRows.Select(entry => new RepoAccountReferenceRow()
{
RepoId = repoID(entry),
Cells = columns.Select(column => column(entry).Cell).ToArray()
})
};
}
}
}