Files
moadiran/TaxPayerFull/CUSComponent/LTable.razor
mmrbnjd df6c31eac2 ltable
2024-05-05 18:15:37 +03:30

67 lines
3.0 KiB
Plaintext

@using System.Reflection
@using System.ComponentModel.DataAnnotations
@using Shared.DTOs
@typeparam T
<div class="row">
<div class="col-md-12">
<div class="mb-4">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="table-responsive text-nowrap">
<table class="table">
<thead class="table-light">
<tr>
@{
PropertyInfo[] properties = typeof(T).GetProperties();
foreach (var item in properties)
{
if (item.GetCustomAttributes(typeof(DisplayAttribute), false).Length > 0)
{
<th>
@item.CustomAttributes.Where(w => w.AttributeType.Name == "DisplayAttribute").Select(s => s.NamedArguments.Where(w => w.MemberName == "Name").Select(ss => ss.TypedValue.Value).First()).First().ToString()
</th>
}
}
}
</tr>
</thead>
<tbody class="table-border-bottom-0">
@{
foreach (var item in ModelinComponent)
{
<tr>
@{
properties = item.GetType().GetProperties();
foreach (PropertyInfo property in properties)
{
if (property.CustomAttributes.Any(w => w.AttributeType.Name == "DisplayAttribute"))
{
<td>@property.GetValue(item, null)</td>
}
}
}
</tr>
}
}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@code {
[Parameter]
public List<T> ModelinComponent { get; set; } = new List<T>();
}