public static async Task AddTelMoment(GeplandTelMoment moment) { if (_cached == null) { await CreateCache(); } Debug.Assert(_cached != null, nameof(_cached) + " != null"); using (var db = new ApplicationDbContext()) { await db.GeplandeTelMomenten.AddAsync(moment); await db.SaveChangesAsync(); } _cached.Add(moment); await CheckMarktSluiting(); }
public static async Task CheckMarktSluiting() { if (_cached == null) { await CreateCache(); } Debug.Assert(_cached != null, nameof(_cached) + " != null"); var datum = DateTime.Now.Date; foreach (var geplandTelMoment in _cached) { if (geplandTelMoment.Tijd.Date == datum && DateTime.Now.Hour >= 18) { IsMarktDicht = true; _huidigTelMoment = geplandTelMoment; break; } } }