Hi, I only want the a subject if there are items in the list.
Then I only want a subject line to be created if there is a record belonging to the current user (clientID).
The below code skips through and creates a subject line for all clients in the table / list.
var PLC = _context.PLCBlock.FirstOrDefault();
if (PLC != null)
{
BodyContent = $"";
//}
var Blocks = _context.PLCBlock.ToList();
//var Blocks = from s in _context.PLCBlock.ToList()
// where s.clientID == User.Identity.Name
// select s;
var BodyContentTemp = "";
foreach (var s in Blocks)
{
if (s.clientID == User.Identity.Name)
{
BodyContentTemp = $"The PLC Type is a {s.BlockType} with Number {s.Number} and with a Description of {s.Description}\r\n";
BodyContent = BodyContent + BodyContentTemp;
}
}
}
Thanks,