public Task Execute(IJobExecutionContext context) { var agentsList = _repositoryAgents.GetAll(); foreach (var agent in agentsList) { var metricsList = _metricsAgentClient.GetAllHddMetrics(new GetAllHddMetricsApiRequest { FromTime = _repository.GetMaxDate(agent.AgentId), ToTime = DateTimeOffset.UtcNow, ClientBaseAddress = agent.AgentURL }); if (!object.ReferenceEquals(metricsList, null)) { foreach (var metric in metricsList.Metrics) { _repository.Create(metric, agent.AgentId); } } } return(Task.CompletedTask); }