@using Radzen.Blazor
@using Radzen.Blazor.Rendering

@inherits SchedulerYearViewBase

@code {
    public override RenderFragment Render()
    {
        var appointments = Scheduler?.GetAppointmentsInRange(StartDate, EndDate) ?? Enumerable.Empty<AppointmentData>();

        var maxAppointmentsInSlot = 0;

        if (MaxAppointmentsInSlot != null)
        {
            maxAppointmentsInSlot = MaxAppointmentsInSlot.Value;
        }
        else
        {
            var slotHeight = 100.0;
            maxAppointmentsInSlot = Convert.ToInt32(Math.Floor(slotHeight / 24)) - 1;
        }

        return @<CascadingValue Value=@Scheduler>
                    <YearTimelineView StartDate=@StartDate
                        EndDate=@EndDate
                        StartMonth=@StartMonth
                        MaxAppointmentsInSlot=@maxAppointmentsInSlot
                        MoreText=@MoreText
                        Appointments=@appointments
                        AppointmentMove=OnAppointmentMove />
                </CascadingValue>;
    }
}