Discard past calendar events
This commit is contained in:
parent
bae9f47ed0
commit
ff9a1fff18
1 changed files with 6 additions and 3 deletions
|
@ -122,15 +122,18 @@ namespace BlazorApp.Data
|
||||||
client.DefaultRequestHeaders.Add("Authorization", AuthorizationHeader);
|
client.DefaultRequestHeaders.Add("Authorization", AuthorizationHeader);
|
||||||
var body = await client.GetStringAsync(Url);
|
var body = await client.GetStringAsync(Url);
|
||||||
var events = ParseICal(body);
|
var events = ParseICal(body);
|
||||||
|
|
||||||
|
var now = DateTime.Now;
|
||||||
|
events = events.FindAll(@event => @event.DtStart > now || @event.DtEnd > now);
|
||||||
|
|
||||||
events.Sort((x, y) =>
|
events.Sort((x, y) =>
|
||||||
{
|
{
|
||||||
if (y.DtStart == null)
|
|
||||||
return -1;
|
|
||||||
if (x.DtStart == null)
|
if (x.DtStart == null)
|
||||||
|
return -1;
|
||||||
|
if (y.DtStart == null)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return DateTime.Compare(y.DtStart.Value, x.DtStart.Value);
|
return DateTime.Compare(x.DtStart.Value, y.DtStart.Value);
|
||||||
});
|
});
|
||||||
|
|
||||||
return events;
|
return events;
|
||||||
|
|
Loading…
Reference in a new issue