26 lines
863 B
C#
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()
|
|
})
|
|
};
|
|
}
|
|
|
|
}
|
|
} |