I have a foreach and several conditions within. Basically, I want to show an a link if PTWNoS is null and a span if PTWNoS is not null. The problem is I have a group and I don't know how to build the condition, similar with the one in the second foreach
@foreach (var group in Model.PTWContents.GroupBy(s => new { s.PTWMain.PTWId, s.PTWMain.PTWNo }).OrderByDescending(s => s.Key.PTWNo))
{
@if (User.IsInRole("PTWIsoCert"))
{
}
else if (User.IsInRole("PTWIsoCert"))
{
@Html.DisplayFor(modelItem => group.Key.PTWNo)
}
else
{
}
@foreach (var item in group.OrderBy(s => s.StartDate))
{
@if (item.PTWSubsequent != null && item.PTWSubsequent.PTWNoS != 0)
{
@if (User.IsInRole("PTWIsoCert"))
{
@Html.DisplayFor(model => item.PTWMain.PTWNo) - @Html.DisplayFor(model => item.PTWSubsequent.PTWNoS)
}
else
{
}
}
else
{
}
}
}
Sachin SinghPosted Sep 4, 2021, 9:39 PM
Marius VasilePosted Sep 4, 2021, 11:48 AM