I have a problem. For a calendar, I would like to display appointments that belong to the logged-in user with details, while all other appointments in the database should be grayed out.
My idea would be that I select in the Select whether the appointment belongs to the registered user or not, if so then show e.g. subject and title of the appointment, else the appointment should be grayed out.
public IActionResult GetEvents()
{
if (User.IsInRole("Member") || User.IsInRole("Admin"))
{
var events = _context.availibilityDtos.AsEnumerable().Select(e => new
{
Subject = e.Subject,
Start = e.Start,
End = e.End ,
Description = e.Description,
IsFullDay = e.IsFullDay,
ThemeColor = e.ThemeColor,
ZFUsername = e.ZFUsername
}).Where(x => x.ZFUsername == User.Identity.Name).ToList();
return new JsonResult(events);
}
else
{
var events = _context.availibilityDtos.ToList();
return new JsonResult(events);
}
How do I best achieve this?
BR Sven
I tried an if loop in select, without success.
Sven is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.