public void Crunch(ptOSContainer context, object obj) { var now = DateTime.UtcNow; var stat = context.Statistics.FirstOrDefault(x => x.Type == Name); if (stat == null) { stat = context.Statistics.Add(new Statistic { Type = Name, At = now, }); } var hourAgo = now.AddHours(-1); stat.Value = context.Events.Count(x => x.Submitted > hourAgo); context.SaveChanges(); }
public BaseApiController() { Context = new ptOSContainer(); }