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.
The is the table
App. 1 | user 1 | 06/15/2024 8:00 | 06/15/2024 9:00 | Test the code |
App. 2 | user 2 | 06/15/2024 8:00 | 06/15/2024 9:00 | Test the code |
App. 3 | user 3 | 06/15/2024 8:00 | 06/15/2024 9:00 | Test the code |
App. 4 | user 1 | 06/15/2024 8:00 | 06/15/2024 9:00 | Test the code |
User1 is logged in and would see the appointments as follows:
App. 1 | user 1 | 06/15/2024 8:00 | 06/15/2024 9:00 | Test the code |
App. 2 | 06/15/2024 8:00 | 06/15/2024 9:00 | ||
App. 3 | 06/15/2024 8:00 | 06/15/2024 9:00 | ||
App. 4 | user 1 | 06/15/2024 8:00 | 06/15/2024 9:00 | Test the code |
In my view I display the calendar using Fullcalendar.io, the events are loaded in the eventSources section, written in ajax. I would now say a foreach loop with the user query, if yes, then show everything, if no, then only show the date and time, field color then gray. However, I am not that well versed in Ajax, I get the data via the GET method, like this:
eventSources: [
{
url: '/Calendar/GetEvents',
method: 'GET',
failure: function () {
alert('there was an error while fetching events!');
},
color: 'orange',
textColor: 'black'
}
]
How can I now insert a foreach loop? Getevents is the array with the appointments, so I would have to open it differently.
BR
Sven
Sven is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.