public async Task RemoveEndpointStatsByDaysToKeep(int daysToKeep) { await using var context = new EpMonContext(); var minDate = DateTime.UtcNow.AddDays(-daysToKeep); await context.Database.ExecuteSqlRawAsync($"DELETE FROM EndpointStats WHERE TimeStamp <= '{minDate.ToString("yyyy-MM-dd HH:mm:ss")}'"); await context.SaveChangesAsync(); }
public void AddEndpointStat(EndpointStat stat) { using var context = new EpMonContext(); context.EndpointStats.Add(new EndpointStat { EndpointId = stat.EndpointId, IsHealthy = stat.IsHealthy, Message = stat.Message, ResponseTime = stat.ResponseTime, TimeStamp = stat.TimeStamp, Status = stat.Status }); context.SaveChanges(); }
public EndpointStore(EpMonContext context) { _context = context; }