public void RemoveEvent(EventScheduled @event, string userName) { if (_db.Storage.ContainsKey(userName)) { _db.Storage[userName].Events.Remove(@event); } }
public void AddEvent(EventScheduled @event, string userName) { if (_db.Storage.ContainsKey(userName)) { _db.Storage[userName]?.Events.Add(@event); } }
public void UpdateEvent(EventScheduled @event, string userName) { if (!_db.Storage.ContainsKey(userName)) { return; } _db.Storage[userName].Events.Remove(_db.Storage[userName].Events.FirstOrDefault(x => x.Id == @event.Id)); _db.Storage[userName].Events.Add(@event); }
public void Schedule(IEvent @event, Time time, Func <int, bool> maySchedule) { var scheduled = new ScheduledEvent(@event, time); Task.Run(async() => { EventScheduled?.Invoke(this, scheduled); while (maySchedule(scheduled.TimesExecuted)) { await waiter.Wait(scheduled.TimeUntil.TotalMilliseconds()); @event.Execute(); scheduled.TimesExecuted++; } EventFinished?.Invoke(this, scheduled); }); }
public void UpdateEvent(EventScheduled @event, string userName) { _repository.UpdateEvent(@event, userName); }
public void RemoveEvent(EventScheduled @event, string userName) { _repository.RemoveEvent(@event, userName); }
public void AddEvent(EventScheduled @event, string userName) { _repository.AddEvent(@event, userName); }