I will also put my OnAfterRenderAsync Method to show I'm not doing anything too funky! Thank you again for looking! protected async override Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { //API Calls to grab available slots, API Returns SlotStart and SlotEnd only as DateTimes iphoneSlots = await _gsxAppointments.getAvalableSlots("IPHONE"); macSlots = await _gsxAppointments.getAvalableSlots("MAC");
//If not null add iPhone slots to the list which is bound to the Scheduler if (iphoneSlots.response != null) { foreach (var slot in iphoneSlots.response.slots) { DataSource.Add(new AppointmentsData { StartTime = DateTime.Parse(slot.start), EndTime = DateTime.Parse(slot.end), Subject = "iPhone Appointment", CategoryColor = "#0275d8" }); } }
//If not null add MAC slots to the list which is bound to the Scheduler if (macSlots.response != null) { foreach (var slot in macSlots.response.slots) { DataSource.Add(new AppointmentsData { StartTime = DateTime.Parse(slot.start), EndTime = DateTime.Parse(slot.end), Subject = "Mac Osx Appointment", CategoryColor = "#5cb85c" }); } }
//Get the earliest slot and set our selection to that date startDate = DataSource.Select(x => x.StartTime).Min(); } }|
@if (DataSource == null) // To check the status of DataSource
{
<p><em>Loading...</em></p>
}
else
{
<SfSchedule TValue="AppointmentsData" Height="650px" CurrentView="View.Week" SelectedDate="@startDate">
<ScheduleEvents TValue="AppointmentsData">
</ScheduleEvents>
<ScheduleEventSettings TValue="AppointmentsData" DataSource="@DataSource">
<Template>
<div class="template-wrap" style="background: @((context as AppointmentsData).CategoryColor)">@((context as AppointmentsData).StartTime.ToString("HH:mm")) - @((context as AppointmentsData).Subject)</div>
</Template>
</ScheduleEventSettings>
</SfSchedule>
}
... |