Is there any way to get a list of ongoing events of a particular date from server side?

Let me know if there's any helper method for getting a list of ongoing events of a particular date from the server-side? Just filtering over start date/time and end date/time isn't enough as many events may have a recurrence which would be filtered out if this is done. 


1 Reply

VD Vinitha Devi Murugan Syncfusion Team July 30, 2021 08:27 AM UTC

Hi Muhaiminul, 
 
Greetings from Syncfusion Support. 
 
We have validated your reported query “Let me know if there's any helper method for getting a list of ongoing events of a particular date from the server-side” and you can get the list of ongoing events of particular date with the help of RecurrenceHelper utility. Please refer below UG link for more information..  
 
 
We have prepared below sample for your reference with RecurrenceHelper utility. 
 
public List<ScheduleEventLoadData([FromBody]Params param) 
{ 
    var data = _context.ScheduleEvents.ToList(); 
 
    DateTime startdate = DateTime.Today; 
    DateTime enddate = startdate.AddDays(1); 
    List<ScheduleEventappCollection = new List<ScheduleEvent>(); 
    for (var i =0idata.Counti++) 
    { 
        var app = data[i]; 
        if (data[i].RecurrenceRule !=  null) {   
            TimeSpan diff = app.EndTime.Subtract(app.StartTime); 
            var recurrenceRule = data[i].RecurrenceRule; 
            TimeSpan startDiff; 
            var dateCollection = RecurrenceHelper.GetRecurrenceDateTimeCollection(recurrenceRuleapp.StartTime); 
            foreach (var date in dateCollection) 
            { 
                startDiff = app.StartTime.Subtract(date); 
                break; 
            } 
                foreach (var date in dateCollection) 
            { 
                var start = date.Add(startDiff); 
                var end = start.Add(diff); 
                appCollection.Add(new ScheduleEvent {  Subject=app.SubjectStartTime = startEndTime = endCategoryId=app.CategoryIdDescription = app.DescriptionIsAllDay =app.IsAllDayRecurrenceRule = app.RecurrenceRuleLocation = app.Location,ProjectId = app.ProjectIdStartTimezone = app.StartTimezoneEndTimezone = app.EndTimezone,Id = app.Id }); 
            } 
        } 
        else 
        { 
            appCollection.Add(app); 
        } 
    } 
    // Here we fileter the today appointment from the db 
    var todayAppointmentCollection = appCollection.Where(app => (app.StartTime >= param.StartDate && app.StartTime <= param.EndDate)).ToList();   
    Console.WriteLine(todayAppointmentCollection); // Now the today appointment available in 'todayAppointemntCollection variable.' 
    return data; 
} 
 
Kindly try with the above solution and get back to us if you need any further assistance 
 
Regards, 
Vinitha 


Loader.
Up arrow icon