Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144147 | Apr 22,2019 01:31 PM UTC | Apr 24,2019 06:31 AM UTC | ASP.NET Core - EJ 2 | 1 |
![]() |
Tags: Scheduler |
[HttpPost]
public List<ScheduleEvent> LoadData([FromBody]Params param)
{
var data = _context.ScheduleEvents.ToList();
DateTime startdate = DateTime.Today;
DateTime enddate = startdate.AddDays(1);
List<ScheduleEvent> appCollection = new List<ScheduleEvent>();
for (var i = 0; i < data.Count; i++)
{
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(recurrenceRule, DateTime.Now);
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.Subject, StartTime = start, EndTime = end, CategoryId = app.CategoryId, Description = app.Description, IsAllDay = app.IsAllDay, RecurrenceRule = app.RecurrenceRule, Location = app.Location, ProjectId = app.ProjectId, StartTimezone = app.StartTimezone, EndTimezone = app.EndTimezone, Id = app.Id });
}
}
else
{
appCollection.Add(app);
}
}
// Here we filter the today appointment from the db
var todayAppointmentCollection = appCollection.Where(app => (app.StartTime >= startdate && app.StartTime <= enddate)).ToList();
Console.WriteLine(todayAppointmentCollection); // Now the today appointment available in todayAppointemntCollection variable.
return data;
}
public class Params
{
public string StartDate { get; set; }
public string EndDate { get; set; }
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.